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 )undefined

Registers keyCode for name.

2 Params
name String

Name for the key code

keyCode NumberArrayNumber

A key code or array of key codes

Returns
undefined

addAllFunction

addAll( set )undefined

Registers a set of key codes.

1 Param
set ObjectString

A map of names to keyCodes

Returns
undefined

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 )undefined

Unregisters keyCode from name.

2 Params
name String

Name for the key code

keyCode NumberArrayNumber

A key code or array of key codes

Returns
undefined

removeAllFunction

removeAll( set )undefined

Unregisters a set of key codes.

1 Param
set Object

A map of names to keyCodes

Returns
undefined
ArrayBooleanFunctionModuleNumberObjectString