Show / Hide Table of Contents

Class KeyState

Wrapper around the game keystate buffer, which contains the pressed state for all keyboard keys, indexed by virtual vkCode.

Inheritance
System.Object
KeyState
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
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 Source

KeyState(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 Source

Item[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.

| Improve this Doc View Source

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 Source

ClearAll()

Clears the pressed state for all keys.

Declaration
public void ClearAll()
| Improve this Doc View Source

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().

| Improve this Doc View Source

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().

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX