Skip to content

Commit

Permalink
Rework hotkey string format note
Browse files Browse the repository at this point in the history
  • Loading branch information
iansan5653 committed Dec 7, 2023
1 parent f3ab302 commit 95871ed
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions README.md
Expand Up @@ -105,12 +105,15 @@ for (const el of document.querySelectorAll('[data-shortcut]')) {
3. Multiple hotkeys (aliases) are separated by a `,`. For example the hotkey `a,b` would activate if the user typed `a` or `b`.
4. Multiple keys separated by a blank space represent a key sequence. For example the hotkey `g n` would activate when a user types the `g` key followed by the `n` key.
5. Modifier key combos are separated with a `+` and are prepended to a key in a consistent order as follows: `"Control+Alt+Meta+Shift+KEY"`.
6. `"Mod"` is a special modifier that localizes to `Meta` on MacOS/iOS, and `Control` on Windows/Linux.
6. `"Shift"` should be included if it would be held and the key is uppercase: ie, `Shift+A` not `A`
1. However, note that MacOS outputs lowercase keys when `Meta+Shift` is held (ie, `Meta+Shift+a`)
7. `"Mod"` is a special modifier that localizes to `Meta` on MacOS/iOS, and `Control` on Windows/Linux.
1. `"Mod+"` can appear in any order in a hotkey string. For example: `"Mod+Alt+Shift+KEY"`
2. Neither the `Control` or `Meta` modifiers should appear in a hotkey string with `Mod`.
7. `"Plus"` and `"Space"` are special key names to represent the `+` and ` ` keys respectively, because these symbols cannot be represented in the normal hotkey string syntax.
8. You can use the comma key `,` as a hotkey, e.g. `a,,` would activate if the user typed `a` or `,`. `Control+,,x` would activate for `Control+,` or `x`.
9. `"Shift"` should be included if it would be held and the key is uppercase: ie, `Shift+A` not `A`. Note however that MacOS outputs lowercase keys when `Meta+Shift` is held (ie, `Meta+Shift+a`); see 6.3 above.
2. Neither the `Control` or `Meta` modifiers should appear in a hotkey string with `Mod`
3. Per 6.1 above, MacOS will output lowercase keys when `Meta` is held. To make `Mod` work across platforms, `hotkey` attempts to normalize this by converting these key values to their 'uppercase' equivalents (including numbers and symbols). This normalization is limited to US keyboard layouts, however.
8. `"Plus"` and `"Space"` are special key names to represent the `+` and ` ` keys respectively, because these symbols cannot be represented in the normal hotkey string syntax.
9. You can use the comma key `,` as a hotkey, e.g. `a,,` would activate if the user typed `a` or `,`. `Control+,,x` would activate for `Control+,` or `x`.


### Example

Expand Down

0 comments on commit 95871ed

Please sign in to comment.