core/keymap

Manages a map of names to key codes to simplify event handlers

Example:

import {add, is} from '@enact/core/keymap';

add('enter', 13);
const isEnter = is('enter');

// within event handler
if (isEnter(ev.keyCode)) {
  // handle enter
}
import keymap from '@enact/core/keymap';

Members

addFunction

add(name, keyCode)

Registers keyCode for name.

2 Params
name String

Name for the key code

keyCode ArrayNumberNumber

A key code or array of key codes

addAllFunction

addAll(set)

Registers a set of key codes.

1 Param
set Object

A map of names to keyCodes

isFunction

is(name, keyCode)Boolean

Determines if keyCode is mapped to name.

2 Params
name String

Name for the key code

keyCode Number

A key code

Returns
Boolean

true if keyCode is mapped to name

removeFunction

remove(name, keyCode)

Unregisters keyCode from name.

2 Params
name String

Name for the key code

keyCode ArrayNumberNumber

A key code or array of key codes

removeAllFunction

removeAll(set)

Unregisters a set of key codes.

1 Param
set Object

A map of names to keyCodes

ArrayBooleanFunctionModuleNumberObjectString