ShortcutManager
Plugin: ShortcutManager
Description
The ShortcutManager API lets you store and manage keyboard shortcut contexts (ShortcutContext).
Each ShortcutManager object:
- Stores and manages its own set of keyboard shortcut contexts.
- Listens to the
KeyboardEventevents and runs actions for them.
Methods
addContext
shortcutManager.addContext(contextName, [scope]) ⇒ object
Create a new ShortcutContext object.
| Param | Type | Default | Description |
|---|---|---|---|
| contextName | string | The name of the new shortcut context | |
| [scope] | string | ”table” | optional The scope of the shortcut: 'table' or 'global' |
destroy
shortcutManager.destroy() : function
Destroy a context manager instance.
getActiveContextName
shortcutManager.getActiveContextName() ⇒ string
Get the ID of the active ShortcutContext.
getContext
shortcutManager.getContext(contextName) ⇒ object | undefined
Get a keyboard shortcut context by its name.
| Param | Type | Description |
|---|---|---|
| contextName | string | The name of the shortcut context. |
Returns: object | undefined - A ShortcutContext object that stores registered shortcuts.
getOrCreateContext
shortcutManager.getOrCreateContext(contextName, [scope]) ⇒ object
Get a keyboard shortcut context by its name, or create it if it doesn’t exist.
| Param | Type | Default | Description |
|---|---|---|---|
| contextName | string | The name of the shortcut context | |
| [scope] | string | ”table” | optional The scope of the shortcut: 'table' or 'global' |
Returns: object - A ShortcutContext object that stores registered shortcuts
isCtrlPressed
shortcutManager.isCtrlPressed() ⇒ boolean
Returns whether control or meta keys are pressed.
releasePressedKeys
shortcutManager.releasePressedKeys() : function
Release every previously pressed key.
setActiveContextName
shortcutManager.setActiveContextName(contextName)
Start listening to keyboard shortcuts within a given ShortcutContext.
| Param | Type | Description |
|---|---|---|
| contextName | string | The name of the shortcut context |