utils/keyboard
@ckeditor/ckeditor5-utils/src/keyboard
Set of utils related to keyboard support.
Filtering
Constants
-
keyCodes
static
Object with
keyName => keyCode
pairs for a set of known keys.Contains:
a-z
,0-9
,f1-f12
,arrow(left|up|right|bottom)
,backspace
,delete
,enter
,esc
,tab
,ctrl
,cmd
,shift
,alt
.
Interfaces
-
Information about a keystroke.
Functions
-
getCode( Key ) → Number
static
Converts a key name or a keystroke info into a key code.
Note: Key names are matched with
keyCodes
in a case-insensitive way.Parameters
Key : String | KeystrokeInfo
name (see
keyCodes
) or a keystroke data object.
Returns
Number
Key or keystroke code.
-
getEnvKeystrokeText( keystroke ) → String
static
It translates any keystroke string text like
"CTRL+A"
to an environment–specific keystroke, i.e."⌘A"
on Mac OSX.Parameters
keystroke : String
Keystroke text.
Returns
String
Keystroke text specific for the environment.
-
parseKeystroke( keystroke ) → Number
static
Parses keystroke and returns a keystroke code that will match the code returned by link
getCode
for a corresponding keystroke info.The keystroke can be passed in two formats:
- as a single string – e.g.
ctrl + A
, - as an array of known key names and key codes – e.g.:
[ 'ctrl', 32 ]
(ctrl + space),[ 'ctrl', 'a' ]
(ctrl + A).
Note: Key names are matched with
keyCodes
in a case-insensitive way.Note: Only keystrokes with a single non-modifier key are supported (e.g.
ctrl+A
is OK, butctrl+A+B
is not).Parameters
keystroke : String | Array.<(Number | String)>
Keystroke definition.
Returns
Number
Keystroke code.
- as a single string – e.g.