Struct KeyboardShortcut
A keyboard shortcut that can be used in Update method to check if user presses a key combo. The shortcut is only
triggered when the user presses the exact combination. For example, F + LeftCtrl
will trigger only if user
presses and holds only LeftCtrl, and then presses F. If any other keys are pressed, the shortcut will not trigger.
Can be used as a value of a setting in Bind<T>(ConfigDefinition, T, ConfigDescription)
to allow user to change this shortcut and have the changes saved.
How to use: Use IsDown() in this class instead of in the
Update loop.
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Assembly: BepInEx.Unity.Mono.dll
Syntax
public struct KeyboardShortcut
Constructors
Create a new keyboard shortcut.
Declaration
public KeyboardShortcut(KeyCode mainKey, params KeyCode[] modifiers)
Parameters
Type |
Name |
Description |
KeyCode |
mainKey |
Main key to press
|
KeyCode[] |
modifiers |
Keys that should be held down before main key is registered
|
Fields
Shortcut that never triggers.
Declaration
public static readonly KeyboardShortcut Empty
Field Value
Properties
Main key of the key combination. It has to be pressed / let go last for the combination to be triggered.
If the combination is empty, is returned.
Declaration
public readonly KeyCode MainKey { get; }
Property Value
Modifiers of the key combination, if any.
Declaration
public readonly IEnumerable<KeyCode> Modifiers { get; }
Property Value
Type |
Description |
System.Collections.Generic.IEnumerable<KeyCode> |
|
Methods
Attempt to deserialize key combination from the string.
Declaration
public static KeyboardShortcut Deserialize(string str)
Parameters
Type |
Name |
Description |
System.String |
str |
|
Returns
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
Check if the main key was just pressed (Input.GetKeyDown), and specified modifier keys are all pressed
Declaration
Returns
Type |
Description |
System.Boolean |
|
Check if the main key is currently held down (Input.GetKey), and specified modifier keys are all pressed
Declaration
Returns
Type |
Description |
System.Boolean |
|
Check if the main key was just lifted (Input.GetKeyUp), and specified modifier keys are all pressed.
Declaration
Returns
Type |
Description |
System.Boolean |
|
Serialize the key combination into a user readable string.
Declaration
public string Serialize()
Returns
Type |
Description |
System.String |
|
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()