Skip to content

Commit

Permalink
Document deprecation of OneShot keys (#1023)
Browse files Browse the repository at this point in the history
* Document deprecation of OneShot keys

added docstring to oneshot.py
added deubug message in module's __init__
changed docs to made deprecation of oneshot keys clear.
  • Loading branch information
MasterTrainerPK authored Aug 31, 2024
1 parent 902f6a6 commit fe0f785
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/en/oneshot.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# OneShot Keycodes

OneShot keys or sticky keys enable you to have keys that keep staying pressed
> [!WARNING]
> OneShot Keys have been depricated in favor of [StickyKeys](sticky_keys.md)
> and will be removed at a future date.
OneShot 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
If the timeout expires or other keys are pressed, and the OneShot key wasn't
released, it is handled as a regular key hold.

## Enable OneShot Keys
Expand All @@ -17,9 +21,9 @@ keyboard.modules.append(oneshot)

## Keycodes

|Keycode | Aliases |Description |
|-----------------|--------------|----------------------------------|
|`KC.OS(KC.ANY)` | `KC.ONESHOT` |make a sticky version of `KC.ANY` |
|Keycode | Aliases |Description |
|-----------------|--------------|-----------------------------------|
|`KC.OS(KC.ANY)` | `KC.ONESHOT` |make a oneshot version of `KC.ANY` |

`KC.ONESHOT` accepts any valid key code as argument, including modifiers and KMK
internal keys like momentary layer shifts.
Expand All @@ -30,7 +34,7 @@ The full OneShot signature is as follows:

```python
KC.OS(
KC.TAP, # the sticky keycode
KC.TAP, # the oneshot keycode
tap_time=None # length of the tap timeout in milliseconds
)
```
Expand Down
5 changes: 5 additions & 0 deletions kmk/modules/oneshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ def __init__(self, kc, tap_time=None, **kwargs):


class OneShot(HoldTap):
'''This module is deprecated; use sticky_keys instead.'''

tap_time = 1000

def __init__(self):
super().__init__()
debug(
'Warning: OneShot module is deprecated and will be removed; use sticky_keys instead.'
)
make_argumented_key(
names=('OS', 'ONESHOT'),
constructor=OneShotKey,
Expand Down

0 comments on commit fe0f785

Please sign in to comment.