-
-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
Body:
Feature Request
Description
It would be great to add support for double-tap hotkeys (sequential key presses) as an alternative to simultaneous key combinations.
Example use cases:
Ctrl+Ctrl(double-tap Ctrl)Alt+Alt(double-tap Alt)Shift+Shift(double-tap Shift)
Why is this useful?
- Ergonomics — double-tap is easier to press than modifier+key combinations
- Fewer conflicts — most applications don't use double-tap shortcuts, so less chance of hotkey collision
- Popular pattern — many tools use this approach (e.g., JetBrains IDEs use double-Shift for "Search Everywhere", IntelliJ uses double-Ctrl for "Run Anything")
- Accessibility — single-hand operation without stretching fingers
Suggested implementation
The pynput library supports this through event timing. Here's a basic approach:
from pynput import keyboard
import time
class DoubleTapDetector:
def __init__(self, key, callback, threshold=0.3):
self.key = key
self.callback = callback
self.threshold = threshold # seconds
self.last_press = 0
self.last_release = 0
def on_press(self, key):
if key == self.key:
current = time.time()
# Check if this is a double-tap
if current - self.last_release < self.threshold:
self.callback()
self.last_press = current
def on_release(self, key):
if key == self.key:
self.last_release = time.time()Alternative libraries
If pynput proves limiting, consider:
| Library | Pros | Docs |
|---|---|---|
| keyboard | Built-in keyboard.add_hotkey('ctrl+ctrl', func) syntax, simpler API |
GitHub |
| python-xlib | Low-level X11 access, full control | Docs |
| evdev | Direct input device access on Linux | Docs |
The keyboard library might be the easiest path — it already supports sequences and double-tap patterns natively:
import keyboard
# Double-tap Ctrl
keyboard.add_hotkey('ctrl+ctrl', invoke_writing_tools)
# Or with custom timing
keyboard.add_hotkey('ctrl, ctrl', invoke_writing_tools, timeout=0.3)Configuration suggestion
Allow users to specify hotkey type in config:
{
"hotkey": "ctrl+ctrl",
"hotkey_type": "double-tap" // or "simultaneous"
}Environment
- OS: Linux (X11/Wayland), Windows
- Writing Tools version: v8
Thank you for this amazing tool! 🙏
Metadata
Metadata
Assignees
Labels
No labels