Keyboard shortcuts - litejs/ui GitHub Wiki

Manage keyboard shortcuts at View level

You can easily setup key bindings with kb attribute in views.

@view public #body
	&kb: {h: history.setUrl.bind(null, "home"), u: history.setUrl.bind(null, "users"), "shift+s": history.setUrl.bind(null, "settings")}
	...

Manage keyboard shortcuts at javascript

var goHomeView = history.setUrl.bind(null, "home")
, keyboardShortcuts = {
	h: goHomeView,
	"shift+h": goHomeView,
	"ctrl+h": goHomeView,
	"alt+h": goHomeView,
	"mod+h": goHomeView, // `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)