Struct InputKey
Represents a unique input key combining device type, key code, modifiers, and device index. Uses value semantics for efficient dictionary lookups and comparisons.
public struct InputKey : IEquatable<InputKey>
- Implements
- Inherited Members
Properties
Code
The specific key/button code for this input.
public readonly int Code { get; }
Property Value
DeviceIndex
Device index for multiple devices (primarily used for gamepads).
public readonly int DeviceIndex { get; }
Property Value
Modifiers
Input modifiers (Ctrl, Shift, Alt) applied to this input.
public readonly InputModifiers Modifiers { get; }
Property Value
Type
The type of input device (Keyboard, Mouse, Gamepad).
public readonly InputType Type { get; }
Property Value
Methods
Equals(InputKey)
Checks equality between two InputKey instances.
public bool Equals(InputKey other)
Parameters
otherInputKey
Returns
Equals(object)
Checks equality with any object.
public override bool Equals(object obj)
Parameters
objobject
Returns
Gamepad(GamepadButton, int)
Creates a gamepad input key.
public static InputKey Gamepad(GamepadButton button, int deviceIndex = 0)
Parameters
buttonGamepadButtonThe gamepad button
deviceIndexintThe gamepad device index (0-3)
Returns
- InputKey
A new InputKey representing the gamepad input
GamepadAxis(GamepadAxis, int)
Gamepad axis as a digital key (pressed while past threshold). Used for triggers.
public static InputKey GamepadAxis(GamepadAxis axis, int deviceIndex = 0)
Parameters
axisGamepadAxisdeviceIndexint
Returns
GetHashCode()
Generates a hash code for efficient dictionary lookups.
public override int GetHashCode()
Returns
Keyboard(KeyboardKey, InputModifiers)
Creates a keyboard input key.
public static InputKey Keyboard(KeyboardKey key, InputModifiers modifiers = InputModifiers.None)
Parameters
keyKeyboardKeyThe keyboard key
modifiersInputModifiersOptional modifiers (Ctrl, Shift, Alt)
Returns
- InputKey
A new InputKey representing the keyboard input
Mouse(MouseButton, InputModifiers)
Creates a mouse input key.
public static InputKey Mouse(MouseButton button, InputModifiers modifiers = InputModifiers.None)
Parameters
buttonMouseButtonThe mouse button
modifiersInputModifiersOptional modifiers (Ctrl, Shift, Alt)
Returns
- InputKey
A new InputKey representing the mouse input
ToString()
Returns a string representation of the input key.
public override string ToString()
Returns
Operators
operator ==(InputKey, InputKey)
Equality operator.
public static bool operator ==(InputKey left, InputKey right)
Parameters
Returns
operator !=(InputKey, InputKey)
Inequality operator.
public static bool operator !=(InputKey left, InputKey right)