Table of Contents

Class KeyboardShortcuts

A class for storing, loading and accessing keyboard shortcuts for defined actions.

public class KeyboardShortcuts : MonoBehaviour
Inheritance
KeyboardShortcuts

Properties

shortcuts

A key is an action name. A value is a list of the keyboard shortcuts for that action.

public static Dictionary<string, List<KeyboardShortcut>> shortcuts { get; }

Property Value

Dictionary<string, List<KeyboardShortcut>>

Methods

AddShortcut(string, params CustomKeyCode[])

Combines the given keycodes into a single shortcut and adds it for the given action.

public static void AddShortcut(string actionName, params CustomKeyCode[] keyCodes)

Parameters

actionName string
keyCodes CustomKeyCode[]

AddShortcut(string, KeyboardShortcut)

Adds the given shortcut for the given action.

public static void AddShortcut(string actionName, KeyboardShortcut shortcut)

Parameters

actionName string
shortcut KeyboardShortcut

ClearShortcutsFor(string)

Removes all shortcuts for the action.

public static void ClearShortcutsFor(string actionName)

Parameters

actionName string

ContainsKey(string)

Returns true if the action is defined for having keyboard shortcuts.

public static bool ContainsKey(string actionName)

Parameters

actionName string

Returns

bool

ContainsShortcutFor(string)

Returns true if the action has a shortcut.

public static bool ContainsShortcutFor(string actionName)

Parameters

actionName string

Returns

bool

GetShortcutsFor(string)

Returns all shortcuts for the action.

public static List<KeyboardShortcut> GetShortcutsFor(string actionName)

Parameters

actionName string

Returns

List<KeyboardShortcut>

LoadShortcuts()

Loads saved shortcuts from the disk.

public static void LoadShortcuts()

SaveShortcuts()

Saves the current assignment of each shortcut to the disk.

public static void SaveShortcuts()

SetShortcut(string, KeyboardShortcut)

Removes any existing shortcuts for the action then adds the given shortcut.

public static void SetShortcut(string actionName, KeyboardShortcut shortcut)

Parameters

actionName string
shortcut KeyboardShortcut