-
-
Notifications
You must be signed in to change notification settings - Fork 0
Keyboard shortcuts
Lauri Rooden edited this page Feb 18, 2026
·
2 revisions
Use @kb in view templates to bind keyboard shortcuts.
Shortcuts are automatically added when the view opens and removed when it closes.
%view home #public
@kb {h: "home", u: "users", "ctrl+s": save}
...
String values navigate to the view, function values are called directly.
El.addKb and El.rmKb can be used directly,
but require manual cleanup — prefer the template version above.
var goHome = $ui.show.bind(null, "home")
, keyboardShortcuts = {
h: goHome,
"shift+h": goHome,
"ctrl+h": goHome,
"alt+h": goHome,
"mod+h": goHome, // `command+h` on Mac and `ctrl+h` on PC
bubble: true, // bubble up to previous map if key not found (default: false)
input: true // capture keys in input/textareas (default: false)
}
// bind
El.addKb(keyboardShortcuts)
// unbind
El.rmKb(keyboardShortcuts)| Modifier | Key |
|---|---|
shift+ |
Shift |
ctrl+ |
Control |
alt+ |
Alt/Option |
mod+ |
Command on Mac, Control on PC |
| Option | Default | Effect |
|---|---|---|
bubble |
false |
Bubble up to previous keyboard map if key not found |
input |
false |
Capture keys even when focus is in input/textarea |
Copyright (c) 2006-2026 Lauri Rooden <lauri@rooden.ee>
MIT License |
GitHub repo |
npm package |
Buy Me A Tea