Skip to content
jigish edited this page Jan 25, 2013 · 14 revisions

Keystrokes are the way you describe key combinations to Slate. This page describes them in detail.

Usage

Keystrokes are used in the slate.bind function:

slate.bind(keystroke, operation);

This will bind operation to run when they key combination described by keystroke is pressed.

Description

There are two types of keystrokes. Normal and Modal.

Normal Keystrokes

Normal keystrokes activate as you would expect. When the keystroke is pressed, the binding activates.

Normal keystrokes are Strings in the following form:

"key:modifiers"
  • key is one of the Allowed Keys
  • modifiers is a comma or semicolon separated list of standard modifier keys:
    • Control: ctrl
    • Option/Alt: alt
    • Command: cmd
    • Shift: shift
    • Function: fn (currently does not work with arrow keys)

Examples

"1:ctrl" - represents pressing 1 and the modifier Control simultaneously

"pad1:ctrl,shift" - represents pressing the 1 key on the number pad and the modifiers Control and Shift all simultaneously

"f10:alt,cmd,fn" - represents pressing the f10 key and the modifiers Option/Alt, Command and Function all simultaneously

Modal Keystrokes

Modal keystrokes activate by defining a modal keystroke that will put Slate into Modal Mode. When in this mode, Slate's menu bar icon will turn blue and Slate will listen for another key press to activate the binding. Once a binding is activated, Modal Mode will end. You may also specify an option that will cause Modal Mode to not exit when the binding is pressed. Instead it will exit if you press the modal keystroke again or use the config modalEscapeKey to specify a modal escape key.

Allowed Keys

Note: If you bind any binding to cmd-tab or cmd-shift-tab, Slate will completely disable the default Mac OS X Application switcher!

'
,
-
.
/
0
1
2
3
4
5
6
7
8
9
;
=
`
a
b
backslash
c
caps
d
delete
down
e
end
esc
f
f1
f10
f11
f12
f13
f14
f15
f16
f17
f18
f19
f2
f20
f3
f4
f5
f6
f7
f8
f9
g
h
help
home
i
j
k
l
left
m
mute
n
o
p
pad*
pad+
pad-
pad.
pad/
pad0
pad1
pad2
pad3
pad4
pad5
pad6
pad7
pad8
pad9
pad=
padClear
padEnter
pageDown
pageUp
q
r
return
right
s
space
t
tab
u
up
v
w
x
y
z
[
]

Clone this wiki locally