Analyzes key events for shortcuts.
Access:
app.getService('keyAnalyzer')
App code:
const keyAnalyzer = app.getService('keyAnalyzer');
Plugin:
const keyAnalyzer = this.app.getService('keyAnalyzer');
analyze#
Wraps a keyboard event in a KeyRules instance with precomputed modifier and key flags (ctrl, shift, enter, arrows, alpha, etc.).
Parameters:
- event (
Event) — native DOM event
Returns: KeyRules
const key = keyAnalyzer.analyze(event);
is#
On the KeyRules object returned by analyze(): returns true if any of the given rule names match the event (e.g. enter, backspace, select, left).
Parameters:
- ...names (
Array) — list of names to process
Returns: boolean
keyAnalyzer.analyze(event).is('enter');
key#
On the KeyRules object returned by analyze(): returns the native KeyboardEvent.key value.
Returns: string
keyAnalyzer.analyze(event).key();
code#
On the KeyRules object returned by analyze(): returns the native KeyboardEvent.code value.
Returns: string
keyAnalyzer.analyze(event).code();