This is the full developer documentation for shortcutter # Page not found > This page does not exist, or it moved. Press ⌘K or Ctrl K to search the docs. # Getting started > Install shortcutter and register your first keyboard shortcut. shortcutter is a tiny, dependency-free library for keyboard shortcuts in the browser. Shortcuts live in **contexts** and fire in **phases**, so a modal, an editor and the rest of your app can each have their own keys. ## Install [Section titled “Install”](#install) * pnpm ```sh pnpm add shortcutter ``` * npm ```sh npm install shortcutter ``` * yarn ```sh yarn add shortcutter ``` ## Your first shortcut [Section titled “Your first shortcut”](#your-first-shortcut) ```ts import { createShortcutter } from 'shortcutter'; const shortcutter = createShortcutter(); // Opens the palette with ⌘ K on macOS and Ctrl K elsewhere. const off = shortcutter.listen('ControlOrMeta+K', () => openCommandPalette(), { preventDefault: true, }); off(); // removes it again ``` Press `⌘` + `K` on macOS or `Ctrl` + `K` elsewhere. Tip `ControlOrMeta` is the same name Playwright uses: `⌘` on macOS, `Ctrl` on Windows and Linux. ## Phases [Section titled “Phases”](#phases) A handler runs when the shortcut goes **down** unless you ask for more: | Phase | When | | ------- | ------------------------------------------------------------- | | `down` | every key of the shortcut became pressed | | `press` | the shortcut is held and the system repeats the key | | `up` | a key was released, another key joined, or the window blurred | ```ts // Hold Alt to show hints shortcutter.listen('Alt', (_event, { phase }) => toggleHints(phase === 'down'), { phases: ['down', 'up'], }); ``` ## Contexts [Section titled “Contexts”](#contexts) Only shortcuts in active contexts run. Every shortcut belongs to `default` unless you pass a context. ```ts shortcutter.listen('Escape', closeModal, { context: 'modal' }); shortcutter.contexts.activate('modal'); // only modal shortcuts run shortcutter.contexts.activate('modal', 'default'); // both, modal first ``` Caution Shortcuts are ignored while typing in inputs, textareas and contenteditable elements. Pass `ignoreInputs: false` for keys like `Esc` that should work there too. # Use with AI > Give AI coding assistants the shortcutter docs with llms.txt. AI assistants know older libraries better than new ones, and they often guess an API from similar packages. Point them at these files instead, generated from this documentation on every release: | File | What it contains | | ------------------------------------ | --------------------------------------------------------------------------------------- | | [`/llms.txt`](/llms.txt) | An index of the documentation, following the [llms.txt](https://llmstxt.org) convention | | [`/llms-full.txt`](/llms-full.txt) | Every page, including the guides and the API reference | | [`/llms-small.txt`](/llms-small.txt) | The same, with non-essential content removed, for smaller context windows | ## In your assistant [Section titled “In your assistant”](#in-your-assistant) * **Chat assistants:** paste the URL of `llms-full.txt`, or attach the file, before asking for code. * **Coding agents and editors:** add `https://www.shortcutter.dev/llms-full.txt` to the project’s documentation or context sources, or mention it in the agent’s instructions file. ## A prompt that works [Section titled “A prompt that works”](#a-prompt-that-works) ```txt Use the shortcutter library (docs: https://www.shortcutter.dev/llms-full.txt). Register shortcuts with createShortcutter().listen(), give each one a description, and use contexts for modal dialogs. Use ControlOrMeta for Cmd/Ctrl. ``` ## What to check in generated code [Section titled “What to check in generated code”](#what-to-check-in-generated-code) * Shortcut strings use `+` and key names such as `ControlOrMeta+K`, `Shift+Slash`, `Arrow*`, not `mod+k` or arrays of keys. * Phases are `'down'`, `'press'` and `'up'` (default `'down'`); there is no `PHASES` object since 0.3. * Movement in games reads held keys with `isPressed()` or `subscribe()`, not `listen()`. * Sequences come from `shortcutter/sequences`, not from the main entry. # shortcutter ## Modules [Section titled “Modules”](#modules) * [shortcutter](/docs/api/shortcutter/readme/) * [shortcutter/sequences](/docs/api/shortcutter/sequences/readme/) # createShortcutter > **createShortcutter**(`options?`): [`Shortcutter`](/docs/api/shortcutter/type-aliases/shortcutter/) Defined in: [shortcutter.ts:71](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/shortcutter.ts#L71) Creates a shortcut manager listening on `options.target` (or `window`). ## Parameters [Section titled “Parameters”](#parameters) ### options? [Section titled “options?”](#options) [`ShortcutterOptions`](/docs/api/shortcutter/type-aliases/shortcutteroptions/) = `{}` ## Returns [Section titled “Returns”](#returns) [`Shortcutter`](/docs/api/shortcutter/type-aliases/shortcutter/) ## Example [Section titled “Example”](#example) ```ts const shortcutter = createShortcutter(); shortcutter.listen('ControlOrMeta+K', () => openPalette(), { preventDefault: true }); ``` # createSequences > **createSequences**(`shortcutter`, `options?`): [`Sequences`](/docs/api/shortcutter/sequences/type-aliases/sequences/) Defined in: [sequences.ts:93](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L93) Adds key sequences (`'G I'`, Vim-style) to a shortcutter. Optional: import it from `shortcutter/sequences` only if you need it. ## Parameters [Section titled “Parameters”](#parameters) ### shortcutter [Section titled “shortcutter”](#shortcutter) [`Shortcutter`](/docs/api/shortcutter/type-aliases/shortcutter/) ### options? [Section titled “options?”](#options) [`SequencesOptions`](/docs/api/shortcutter/sequences/type-aliases/sequencesoptions/) = `{}` ## Returns [Section titled “Returns”](#returns) [`Sequences`](/docs/api/shortcutter/sequences/type-aliases/sequences/) ## Example [Section titled “Example”](#example) ```ts const sequences = createSequences(shortcutter); sequences.listen('G I', () => goToInbox(), { description: 'Go to the inbox' }); ``` # SequenceDetail > **SequenceDetail** = `object` Defined in: [sequences.ts:11](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L11) ## Properties [Section titled “Properties”](#properties) ### context [Section titled “context”](#context) > **context**: `string` Defined in: [sequences.ts:14](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L14) *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [sequences.ts:15](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L15) *** ### sequence [Section titled “sequence”](#sequence) > **sequence**: `string` Defined in: [sequences.ts:13](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L13) The sequence as passed to `listen()`, e.g. `'G I'`. # SequenceHandler > **SequenceHandler** = (`event`, `detail`) => `void` Defined in: [sequences.ts:19](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L19) `event` is the keydown that completed the sequence. ## Parameters [Section titled “Parameters”](#parameters) ### event [Section titled “event”](#event) `KeyboardEvent` ### detail [Section titled “detail”](#detail) [`SequenceDetail`](/docs/api/shortcutter/sequences/type-aliases/sequencedetail/) ## Returns [Section titled “Returns”](#returns) `void` # SequenceInfo > **SequenceInfo** = `object` Defined in: [sequences.ts:38](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L38) A registered sequence, as listed by `sequences()`. ## Properties [Section titled “Properties”](#properties) ### active [Section titled “active”](#active) > **active**: `boolean` Defined in: [sequences.ts:45](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L45) Whether its context is active, so the sequence works right now. *** ### context [Section titled “context”](#context) > **context**: `string` Defined in: [sequences.ts:42](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L42) *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [sequences.ts:43](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L43) *** ### sequence [Section titled “sequence”](#sequence) > **sequence**: `string` Defined in: [sequences.ts:39](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L39) *** ### steps [Section titled “steps”](#steps) > **steps**: `string`\[]\[] Defined in: [sequences.ts:41](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L41) Canonical keys of every step for this platform, modifiers first: `[['g'], ['i']]`. # SequenceOptions > **SequenceOptions** = `object` Defined in: [sequences.ts:21](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L21) ## Properties [Section titled “Properties”](#properties) ### context? [Section titled “context?”](#context) > `optional` **context?**: `string` Defined in: [sequences.ts:25](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L25) Context to register in. Defaults to `'default'`. *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [sequences.ts:23](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L23) What the sequence does, for help screens built from `sequences()`. *** ### ignoreInputs? [Section titled “ignoreInputs?”](#ignoreinputs) > `optional` **ignoreInputs?**: `boolean` Defined in: [sequences.ts:27](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L27) Skip while typing in form fields or contenteditable. Defaults to `true`. *** ### preventDefault? [Section titled “preventDefault?”](#preventdefault) > `optional` **preventDefault?**: `boolean` Defined in: [sequences.ts:29](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L29) Call `preventDefault()` on the keydown that completes the sequence. Defaults to `false`. # Sequences > **Sequences** = `object` Defined in: [sequences.ts:48](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L48) ## Methods [Section titled “Methods”](#methods) ### destroy() [Section titled “destroy()”](#destroy) > **destroy**(): `void` Defined in: [sequences.ts:58](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L58) Stops matching and removes every sequence. #### Returns [Section titled “Returns”](#returns) `void` *** ### listen() [Section titled “listen()”](#listen) > **listen**(`sequence`, `handler`, `options?`): () => `void` Defined in: [sequences.ts:54](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L54) Runs `handler` when the steps of `sequence` are pressed one after another, e.g. `'G I'`, `'G Shift+P'` or `'ArrowUp ArrowUp ArrowDown ArrowDown'`. Each step is a shortcut (wildcards included); steps are separated by spaces. Returns a function that removes the sequence. #### Parameters [Section titled “Parameters”](#parameters) ##### sequence [Section titled “sequence”](#sequence) `string` ##### handler [Section titled “handler”](#handler) [`SequenceHandler`](/docs/api/shortcutter/sequences/type-aliases/sequencehandler/) ##### options? [Section titled “options?”](#options) [`SequenceOptions`](/docs/api/shortcutter/sequences/type-aliases/sequenceoptions/) #### Returns [Section titled “Returns”](#returns-1) () => `void` *** ### sequences() [Section titled “sequences()”](#sequences) > **sequences**(`filter?`): [`SequenceInfo`](/docs/api/shortcutter/sequences/type-aliases/sequenceinfo/)\[] Defined in: [sequences.ts:56](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L56) Registered sequences in registration order, e.g. to add them to a keyboard help screen. #### Parameters [Section titled “Parameters”](#parameters-1) ##### filter? [Section titled “filter?”](#filter) ###### active? [Section titled “active?”](#active) `boolean` ###### context? [Section titled “context?”](#context) `string` #### Returns [Section titled “Returns”](#returns-2) [`SequenceInfo`](/docs/api/shortcutter/sequences/type-aliases/sequenceinfo/)\[] # SequencesOptions > **SequencesOptions** = `object` Defined in: [sequences.ts:32](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L32) ## Properties [Section titled “Properties”](#properties) ### timeout? [Section titled “timeout?”](#timeout) > `optional` **timeout?**: `number` Defined in: [sequences.ts:34](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/sequences.ts#L34) Most milliseconds between two steps. Defaults to `1000`. # KeysListener > **KeysListener** = (`pressed`, `event`) => `void` Defined in: [types.ts:38](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L38) Gets the keys held right now (sorted canonical names) each time they change. ## Parameters [Section titled “Parameters”](#parameters) ### pressed [Section titled “pressed”](#pressed) `string`\[] ### event [Section titled “event”](#event) `KeyboardEvent` | `Event` ## Returns [Section titled “Returns”](#returns) `void` # ListenOptions > **ListenOptions** = `object` Defined in: [types.ts:61](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L61) ## Properties [Section titled “Properties”](#properties) ### context? [Section titled “context?”](#context) > `optional` **context?**: `string` Defined in: [types.ts:65](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L65) Context to register in. Defaults to the shortcutter’s `defaultContext`. *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [types.ts:63](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L63) What the shortcut does, for help screens built from `shortcuts()`. *** ### ignoreInputs? [Section titled “ignoreInputs?”](#ignoreinputs) > `optional` **ignoreInputs?**: `boolean` Defined in: [types.ts:68](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L68) *** ### phases? [Section titled “phases?”](#phases) > `optional` **phases?**: [`Phases`](/docs/api/shortcutter/type-aliases/phases/) Defined in: [types.ts:67](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L67) Phases to run the handler in. Defaults to `'down'`. *** ### preventDefault? [Section titled “preventDefault?”](#preventdefault) > `optional` **preventDefault?**: `boolean` Defined in: [types.ts:69](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L69) # Phase > **Phase** = `"down"` | `"press"` | `"up"` Defined in: [types.ts:8](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L8) When a handler runs: * `down`: every key of the shortcut became pressed; * `press`: the shortcut is held and the system repeats the key; * `up`: the shortcut stopped being pressed (a key was released, another key joined, or the page lost focus, was left or was hidden). # PhaseListener > **PhaseListener** = (`event`, `detail`) => `void` Defined in: [types.ts:32](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L32) Gets every phase of every key combination, matched or not. ## Parameters [Section titled “Parameters”](#parameters) ### event [Section titled “event”](#event) `KeyboardEvent` | `Event` ### detail [Section titled “detail”](#detail) #### phase [Section titled “phase”](#phase) [`Phase`](/docs/api/shortcutter/type-aliases/phase/) #### shortcut [Section titled “shortcut”](#shortcut) `string` ## Returns [Section titled “Returns”](#returns) `void` # Phases > **Phases** = [`Phase`](/docs/api/shortcutter/type-aliases/phase/) | readonly [`Phase`](/docs/api/shortcutter/type-aliases/phase/)\[] Defined in: [types.ts:11](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L11) One phase or a list of them, e.g. `'down'` or `['down', 'up']`. # ShortcutDetail > **ShortcutDetail** = `object` Defined in: [types.ts:13](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L13) ## Properties [Section titled “Properties”](#properties) ### context [Section titled “context”](#context) > **context**: `string` Defined in: [types.ts:20](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L20) The context the shortcut was registered in. *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [types.ts:22](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L22) The description given to `listen()`, if any. *** ### pattern [Section titled “pattern”](#pattern) > **pattern**: `string` Defined in: [types.ts:18](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L18) The registered shortcut in canonical form, e.g. `'arrow*+shift'`. Same as `shortcut` without wildcards. *** ### phase [Section titled “phase”](#phase) > **phase**: [`Phase`](/docs/api/shortcutter/type-aliases/phase/) Defined in: [types.ts:14](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L14) *** ### shortcut [Section titled “shortcut”](#shortcut) > **shortcut**: `string` Defined in: [types.ts:16](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L16) The keys actually held, in canonical form, e.g. `'arrowup+shift'`. # ShortcutHandler > **ShortcutHandler** = (`event`, `detail`) => `void` Defined in: [types.ts:29](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L29) `event` is the `KeyboardEvent`, or for an `up` caused by releasing every key, the event that did it: `blur`, `pagehide` or `visibilitychange`. ## Parameters [Section titled “Parameters”](#parameters) ### event [Section titled “event”](#event) `KeyboardEvent` | `Event` ### detail [Section titled “detail”](#detail) [`ShortcutDetail`](/docs/api/shortcutter/type-aliases/shortcutdetail/) ## Returns [Section titled “Returns”](#returns) `void` # ShortcutInfo > **ShortcutInfo** = `object` Defined in: [types.ts:75](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L75) A registered shortcut, as listed by `shortcuts()`. ## Properties [Section titled “Properties”](#properties) ### active [Section titled “active”](#active) > **active**: `boolean` Defined in: [types.ts:87](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L87) Whether the shortcut’s context is active, so the shortcut works right now. *** ### context [Section titled “context”](#context) > **context**: `string` Defined in: [types.ts:83](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L83) *** ### description? [Section titled “description?”](#description) > `optional` **description?**: `string` Defined in: [types.ts:85](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L85) *** ### keys [Section titled “keys”](#keys) > **keys**: `string`\[] Defined in: [types.ts:82](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L82) Canonical key names for this platform, modifiers first: `['meta', 'k']` on macOS, `['control', 'k']` elsewhere. Wildcards stay as written, e.g. `'arrow*'`. *** ### phases [Section titled “phases”](#phases) > **phases**: [`Phase`](/docs/api/shortcutter/type-aliases/phase/)\[] Defined in: [types.ts:84](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L84) *** ### shortcut [Section titled “shortcut”](#shortcut) > **shortcut**: `string` Defined in: [types.ts:77](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L77) The shortcut as passed to `listen()`, e.g. `'ControlOrMeta+K'`. # ShortcutsFilter > **ShortcutsFilter** = `object` Defined in: [types.ts:90](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L90) ## Properties [Section titled “Properties”](#properties) ### active? [Section titled “active?”](#active) > `optional` **active?**: `boolean` Defined in: [types.ts:92](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L92) Only shortcuts whose context is active (`true`) or inactive (`false`). *** ### context? [Section titled “context?”](#context) > `optional` **context?**: `string` Defined in: [types.ts:94](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L94) Only shortcuts in this context. # Shortcutter > **Shortcutter** = `object` Defined in: [types.ts:97](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L97) ## Properties [Section titled “Properties”](#properties) ### contexts [Section titled “contexts”](#contexts) > **contexts**: `object` Defined in: [types.ts:110](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L110) #### activate() [Section titled “activate()”](#activate) > **activate**(…`names`): `void` Makes exactly these contexts active; handlers run in this order. Unknown names are allowed. ##### Parameters [Section titled “Parameters”](#parameters) ###### names [Section titled “names”](#names) …`string`\[] ##### Returns [Section titled “Returns”](#returns) `void` #### active() [Section titled “active()”](#active) > **active**(): `string`\[] Names of the active contexts. ##### Returns [Section titled “Returns”](#returns-1) `string`\[] #### isActive() [Section titled “isActive()”](#isactive) > **isActive**(`name`): `boolean` ##### Parameters [Section titled “Parameters”](#parameters-1) ###### name [Section titled “name”](#name) `string` ##### Returns [Section titled “Returns”](#returns-2) `boolean` ## Methods [Section titled “Methods”](#methods) ### destroy() [Section titled “destroy()”](#destroy) > **destroy**(): `void` Defined in: [types.ts:143](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L143) Removes all event listeners. Registered shortcuts stop firing. Safe to call twice. #### Returns [Section titled “Returns”](#returns-3) `void` *** ### isPressed() [Section titled “isPressed()”](#ispressed) > **isPressed**(`shortcut`): `boolean` Defined in: [types.ts:128](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L128) Whether every key of `shortcut` is held right now, other keys may be held too: `isPressed('Shift')`, `isPressed('Shift+W')`, `isPressed('Arrow*')` (any arrow). #### Parameters [Section titled “Parameters”](#parameters-2) ##### shortcut [Section titled “shortcut”](#shortcut) `string` #### Returns [Section titled “Returns”](#returns-4) `boolean` *** ### listen() [Section titled “listen()”](#listen) > **listen**(`shortcut`, `handler`, `options?`): () => `void` Defined in: [types.ts:107](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L107) Runs `handler` when `shortcut` (e.g. `'ControlOrMeta+K'`, `'Shift+ArrowUp'`, `'Escape'`) is used while `context` is active. Returns a function that removes the shortcut. Throws if the same shortcut is already registered for one of the phases in that context. A key may contain `*`: `'Shift+Arrow*'`, `'Digit*'` (any digit), `'Key*'` (any letter), `'F*'` (function keys), `'Control+*'` (any key). Each wildcard matches one key and never a modifier. Within a context, an exact shortcut wins over wildcards for the same keys. #### Parameters [Section titled “Parameters”](#parameters-3) ##### shortcut [Section titled “shortcut”](#shortcut-1) `string` ##### handler [Section titled “handler”](#handler) [`ShortcutHandler`](/docs/api/shortcutter/type-aliases/shortcuthandler/) ##### options? [Section titled “options?”](#options) [`ListenOptions`](/docs/api/shortcutter/type-aliases/listenoptions/) #### Returns [Section titled “Returns”](#returns-5) () => `void` *** ### observe() [Section titled “observe()”](#observe) > **observe**(`listener`): () => `void` Defined in: [types.ts:141](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L141) Calls `listener` for every `down`, `press` and `up` of any key combination, whether or not a shortcut matches it, before matching handlers run. Ignores contexts and the input guard. Returns an unsubscribe function. Useful for key loggers, visualizers and analytics. #### Parameters [Section titled “Parameters”](#parameters-4) ##### listener [Section titled “listener”](#listener) [`PhaseListener`](/docs/api/shortcutter/type-aliases/phaselistener/) #### Returns [Section titled “Returns”](#returns-6) () => `void` *** ### pressed() [Section titled “pressed()”](#pressed) > **pressed**(): `string`\[] Defined in: [types.ts:130](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L130) Canonical names of the keys pressed right now, sorted. #### Returns [Section titled “Returns”](#returns-7) `string`\[] *** ### resolve() [Section titled “resolve()”](#resolve) > **resolve**(`shortcut`): `string`\[] Defined in: [types.ts:123](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L123) Canonical key names of `shortcut` for this instance’s platform, modifiers first: `resolve('ControlOrMeta+K')` is `['meta', 'k']` on macOS. Throws on an invalid shortcut. #### Parameters [Section titled “Parameters”](#parameters-5) ##### shortcut [Section titled “shortcut”](#shortcut-2) `string` #### Returns [Section titled “Returns”](#returns-8) `string`\[] *** ### shortcuts() [Section titled “shortcuts()”](#shortcuts) > **shortcuts**(`filter?`): [`ShortcutInfo`](/docs/api/shortcutter/type-aliases/shortcutinfo/)\[] Defined in: [types.ts:118](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L118) Registered shortcuts in registration order, e.g. to build a keyboard help screen. #### Parameters [Section titled “Parameters”](#parameters-6) ##### filter? [Section titled “filter?”](#filter) [`ShortcutsFilter`](/docs/api/shortcutter/type-aliases/shortcutsfilter/) #### Returns [Section titled “Returns”](#returns-9) [`ShortcutInfo`](/docs/api/shortcutter/type-aliases/shortcutinfo/)\[] *** ### subscribe() [Section titled “subscribe()”](#subscribe) > **subscribe**(`listener`): () => `void` Defined in: [types.ts:135](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L135) Calls `listener` whenever the held keys change, with the new list. Returns an unsubscribe function. Fits `useSyncExternalStore` in React, or any key visualizer. #### Parameters [Section titled “Parameters”](#parameters-7) ##### listener [Section titled “listener”](#listener-1) [`KeysListener`](/docs/api/shortcutter/type-aliases/keyslistener/) #### Returns [Section titled “Returns”](#returns-10) () => `void` *** ### unlisten() [Section titled “unlisten()”](#unlisten) > **unlisten**(`shortcut`, `options?`): `void` Defined in: [types.ts:109](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L109) Removes a shortcut. Does nothing if it is not registered. #### Parameters [Section titled “Parameters”](#parameters-8) ##### shortcut [Section titled “shortcut”](#shortcut-3) `string` ##### options? [Section titled “options?”](#options-1) [`UnlistenOptions`](/docs/api/shortcutter/type-aliases/unlistenoptions/) #### Returns [Section titled “Returns”](#returns-11) `void` # ShortcutterOptions > **ShortcutterOptions** = `object` Defined in: [types.ts:40](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L40) ## Properties [Section titled “Properties”](#properties) ### defaultContext? [Section titled “defaultContext?”](#defaultcontext) > `optional` **defaultContext?**: `string` Defined in: [types.ts:49](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L49) Context that is active from the start and used when `listen()` gets none. Defaults to `'default'`. *** ### ignoreInputs? [Section titled “ignoreInputs?”](#ignoreinputs) > `optional` **ignoreInputs?**: `boolean` Defined in: [types.ts:54](https://github.com/mrpiotr-dev/shortcutter/blob/main/packages/core/src/types.ts#L54) Skip handlers while typing in ``, `