Class KeyState
Wrapper around the game keystate buffer, which contains the pressed state for all keyboard keys, indexed by virtual vkCode.
Inheritance
Inherited Members
Namespace: Dalamud.Game.ClientState.Keys
Assembly: Dalamud.dll
Syntax
public class KeyState
Remarks
The stored key state is actually a combination field, however the below ephemeral states are consumed each frame. Setting the value may be mildly useful, however retrieving the value is largely pointless. In testing, it wasn't possible without setting the statue manually. index & 0 = key pressed. index & 1 = key down (ephemeral). index & 2 = key up (ephemeral). index & 3 = short key press (ephemeral).
Constructors
| Improve this Doc View SourceKeyState(ClientStateAddressResolver)
Initializes a new instance of the KeyState class.
Declaration
public KeyState(ClientStateAddressResolver addressResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| ClientStateAddressResolver | addressResolver | The ClientStateAddressResolver instance. |
Properties
| Improve this Doc View SourceItem[VirtualKey]
Get or set the key-pressed state for a given vkCode.
Declaration
public bool this[VirtualKey vkCode] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| VirtualKey | vkCode |
Property Value
| Type | Description |
|---|---|
| System.Boolean | Whether the specified key is currently pressed. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
| System.ArgumentOutOfRangeException | If the set value is non-zero. |
Item[Int32]
Get or set the key-pressed state for a given vkCode.
Declaration
public bool this[int vkCode] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | vkCode | The virtual key to change. |
Property Value
| Type | Description |
|---|---|
| System.Boolean | Whether the specified key is currently pressed. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
| System.ArgumentOutOfRangeException | If the set value is non-zero. |
Methods
| Improve this Doc View SourceClearAll()
Clears the pressed state for all keys.
Declaration
public void ClearAll()
GetRawValue(VirtualKey)
Gets the value in the index array.
Declaration
public int GetRawValue(VirtualKey vkCode)
Parameters
| Type | Name | Description |
|---|---|---|
| VirtualKey | vkCode |
Returns
| Type | Description |
|---|---|
| System.Int32 | The raw value stored in the index array. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
GetRawValue(Int32)
Gets the value in the index array.
Declaration
public int GetRawValue(int vkCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | vkCode | The virtual key to change. |
Returns
| Type | Description |
|---|---|
| System.Int32 | The raw value stored in the index array. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
GetValidVirtualKeys()
Gets an array of virtual keys the game considers valid input.
Declaration
public VirtualKey[] GetValidVirtualKeys()
Returns
| Type | Description |
|---|---|
| VirtualKey[] | An array of valid virtual keys. |
IsVirtualKeyValid(VirtualKey)
Gets a value indicating whether the given VirtualKey code is regarded as valid input by the game.
Declaration
public bool IsVirtualKeyValid(VirtualKey vkCode)
Parameters
| Type | Name | Description |
|---|---|---|
| VirtualKey | vkCode |
Returns
| Type | Description |
|---|---|
| System.Boolean | If the code is valid. |
IsVirtualKeyValid(Int32)
Gets a value indicating whether the given VirtualKey code is regarded as valid input by the game.
Declaration
public bool IsVirtualKeyValid(int vkCode)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | vkCode | Virtual key code. |
Returns
| Type | Description |
|---|---|
| System.Boolean | If the code is valid. |
SetRawValue(VirtualKey, Int32)
Sets the value in the index array.
Declaration
public void SetRawValue(VirtualKey vkCode, int value)
Parameters
| Type | Name | Description |
|---|---|---|
| VirtualKey | vkCode | |
| System.Int32 | value | The raw value to set in the index array. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
| System.ArgumentOutOfRangeException | If the set value is non-zero. |
SetRawValue(Int32, Int32)
Sets the value in the index array.
Declaration
public void SetRawValue(int vkCode, int value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | vkCode | The virtual key to change. |
| System.Int32 | value | The raw value to set in the index array. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | If the vkCode is not valid. Refer to IsVirtualKeyValid(Int32) or GetValidVirtualKeys(). |
| System.ArgumentOutOfRangeException | If the set value is non-zero. |