2022-02-13 22:30:31 +00:00
|
|
|
# OneShot Keycodes
|
2022-04-20 15:20:46 -05:00
|
|
|
|
2022-02-13 22:30:31 +00:00
|
|
|
OneShot keys or sticky keys enable you to have keys that keep staying pressed
|
|
|
|
for a certain time or until another key is pressed and released.
|
|
|
|
If the timeout expires or other keys are pressed, and the sticky key wasn't
|
|
|
|
released, it is handled as a regular key hold.
|
|
|
|
|
|
|
|
## Enable OneShot Keys
|
|
|
|
|
|
|
|
```python
|
|
|
|
from kmk.modules.oneshot import OneShot
|
|
|
|
oneshot = OneShot()
|
|
|
|
# optional: set a custom tap timeout in ms (default: 1000ms)
|
|
|
|
# oneshot.tap_time = 1500
|
2022-06-24 11:46:00 -07:00
|
|
|
keyboard.modules.append(oneshot)
|
2022-02-13 22:30:31 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Keycodes
|
|
|
|
|
|
|
|
|Keycode | Aliases |Description |
|
2022-02-14 10:55:19 +00:00
|
|
|
|-----------------|--------------|----------------------------------|
|
2022-02-13 22:30:31 +00:00
|
|
|
|`KC.OS(KC.ANY)` | `KC.ONESHOT` |make a sticky version of `KC.ANY` |
|
|
|
|
|
|
|
|
`KC.ONESHOT` accepts any valid key code as argument, including modifiers and KMK
|
|
|
|
internal keys like momentary layer shifts.
|
|
|
|
|
|
|
|
## Custom OneShot Behavior
|
2022-04-20 15:20:46 -05:00
|
|
|
|
2022-02-13 22:30:31 +00:00
|
|
|
The full OneShot signature is as follows:
|
2022-04-20 15:20:46 -05:00
|
|
|
|
2022-02-13 22:30:31 +00:00
|
|
|
```python
|
|
|
|
KC.OS(
|
|
|
|
KC.TAP, # the sticky keycode
|
|
|
|
tap_time=None # length of the tap timeout in milliseconds
|
|
|
|
)
|
|
|
|
```
|
2022-04-20 15:20:46 -05:00
|
|
|
|
2023-02-28 22:34:07 +03:00
|
|
|
|
2022-04-20 15:20:46 -05:00
|
|
|
## OneShot Modifier Combinations
|
|
|
|
|
2023-02-28 22:34:07 +03:00
|
|
|
The OneShot keys can be chained. In this example if you press `OS_LCTL` and then `OS_LSFT` followed by `KC.TAB`, the output will be `ctrl+shift+tab`.
|
2022-04-20 15:20:46 -05:00
|
|
|
|
|
|
|
```python
|
|
|
|
from kmk.modules.oneshot import OneShot
|
|
|
|
|
|
|
|
oneshot = OneShot()
|
|
|
|
keyboard.modules.append(oneshot)
|
|
|
|
|
|
|
|
OS_LCTL = KC.OS(KC.LCTL, tap_time=None)
|
|
|
|
OS_LSFT = KC.OS(KC.LSFT, tap_time=None)
|
|
|
|
|
2023-02-28 22:34:07 +03:00
|
|
|
keyboard.keymap = [[OS_LSFT, OS_LCTL, KC.TAB]]
|
2022-04-20 15:20:46 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
> </details>
|