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 
Syntax
public struct KeyboardShortcutConstructors
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
AllKeyCodes
All KeyCode values that can be used in a keyboard shortcut.
Declaration
[Obsolete("Use UnityInput.Current.SupportedKeyCodes instead")]
public static readonly IEnumerable<KeyCode> AllKeyCodesField Value
| Type | Description | 
|---|---|
| System.Collections.Generic.IEnumerable<KeyCode> | 
Empty
Shortcut that never triggers.
Declaration
public static readonly KeyboardShortcut EmptyField Value
| Type | Description | 
|---|---|
| KeyboardShortcut | 
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, 
Declaration
public readonly KeyCode MainKey { get; }Property Value
| Type | Description | 
|---|---|
| KeyCode | 
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
| Type | Description | 
|---|---|
| KeyboardShortcut | 
Declaration
public override bool Equals(object obj)Parameters
| Type | Name | Description | 
|---|---|---|
| System.Object | obj | 
Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Overrides
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| System.Int32 | 
Overrides
Check if the main key was just pressed (Input.GetKeyDown), and specified modifier keys are all pressed
Declaration
public bool IsDown()Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Check if the main key is currently held down (Input.GetKey), and specified modifier keys are all pressed
Declaration
public bool IsPressed()Returns
| Type | Description | 
|---|---|
| System.Boolean | 
Check if the main key was just lifted (Input.GetKeyUp), and specified modifier keys are all pressed.
Declaration
public bool IsUp()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 |