docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct KeyboardState

    Default state layout for keyboards.

    Implements
    IInputStateTypeInfo
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Namespace: UnityEngine.InputSystem.LowLevel
    Assembly: Unity.InputSystem.dll
    Syntax
    public struct KeyboardState : IInputStateTypeInfo
    Remarks

    Can be used to update the state of Keyboard devices.

    Examples
    using UnityEngine;
    using UnityEngine.InputSystem;
    using UnityEngine.InputSystem.LowLevel;
    
    public class Example : MonoBehaviour
    {
        void Start()
        {
            // Send input event with A key pressed on keyboard.
            InputSystem.QueueStateEvent(Keyboard.current,
                new KeyboardState(Key.A));
        }
    }

    Constructors

    KeyboardState(bool, params Key[])

    Create a new KeyboardState with the given keys pressed.

    Declaration
    public KeyboardState(bool IMESelected, params Key[] pressedKeys)
    Parameters
    Type Name Description
    bool IMESelected

    true if IMESelected state is enable

    Key[] pressedKeys

    pressed keys

    Exceptions
    Type Condition
    ArgumentNullException

    If pressedKeys is null

    See Also
    Keyboard

    KeyboardState(params Key[])

    Create a new KeyboardState with the given keys pressed.

    Declaration
    public KeyboardState(params Key[] pressedKeys)
    Parameters
    Type Name Description
    Key[] pressedKeys

    pressed keys

    Remarks

    IMESelected state will not be set.

    Exceptions
    Type Condition
    ArgumentNullException

    If pressedKeys is null

    See Also
    Keyboard

    Fields

    keys

    Declaration
    public byte* keys
    Field Value
    Type Description
    byte*
    See Also
    Keyboard

    Properties

    Format

    Memory format tag for KeyboardState. Returns "KEYS".

    Declaration
    public static FourCC Format { get; }
    Property Value
    Type Description
    FourCC
    See Also
    format

    format

    Declaration
    public FourCC format { get; }
    Property Value
    Type Description
    FourCC
    See Also
    Keyboard

    Methods

    Press(Key)

    Declaration
    public void Press(Key key)
    Parameters
    Type Name Description
    Key key
    See Also
    Keyboard

    Release(Key)

    Declaration
    public void Release(Key key)
    Parameters
    Type Name Description
    Key key
    See Also
    Keyboard

    Set(Key, bool)

    Declaration
    public void Set(Key key, bool state)
    Parameters
    Type Name Description
    Key key
    bool state
    See Also
    Keyboard

    Implements

    IInputStateTypeInfo

    See Also

    Keyboard
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)