Keymap
Official
Manages keymap lifecycle for different obsidian#Scopes.
Import:
import { Keymap } from 'obsidian';Signature:
export class KeymapConstructor
new Keymap()Constructor.
To get the constructor instance, use getKeymapConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| modifiers | string | The compiled, sorted, comma-joined string of currently-pressed modifiers (e.g. 'Ctrl,Shift'). | |
| rootScope | Scope | The root scope, active when no other scope is pushed. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| getRootScope() | Scope | Gets the root scope. | |
| hasModifier(modifier) | boolean | Checks whether a modifier is currently pressed. | |
| isModEvent(evt?) | PaneType | boolean | Translates an event into the type of pane that should open. Returns 'tab' if the modifier key Cmd/Ctrl is pressed OR if this is a middle-click MouseEvent. Returns 'split' if Cmd/Ctrl+Alt is pressed. Returns 'window' if Cmd/Ctrl+Alt+Shift is pressed. | |
| isModifier(evt, modifier) | boolean | Checks whether the modifier key is pressed during this event. | |
| matchModifiers(modifiers) | boolean | Checks whether the currently-pressed modifiers exactly match the given compiled modifier string. | |
| onFocusIn(evt) | void | Handles a focus-in event for the keymap's tab-focus handling. | |
| onKeyEvent(evt) | false | void | Handles a key event, dispatching it to the active scope. | |
| popScope(scope) | void | Remove a scope from the scope stack. If the given scope is active, the next scope in the stack will be made active. | |
| pushScope(scope) | void | Push a scope onto the scope stack, setting it as the active scope to handle all key events. | |
| updateModifiers(evt) | void | Updates the currently-pressed modifiers from a keyboard event. |
Links to this page: