Namespace: key

caph.event. key

Members

<static> type :Object

The enums indicate key code type string. (POWER, SOURCE, HDMI, N0, N1, N2, N3, N4, N5, N6, N7, N8, N9, TTX_MIX, PRE_CH, MUTE, CH_LIST, VOL_DOWN, VOL_UP, CH_DOWN, CH_UP, HOME, MENU, GUIDE, TOOLS, INFO, LEFT, UP, RIGHT, DOWN, ENTER, RETURN, EXIT, RED, GREEN, YELLOW, BLUE, REWIND, PAUSE, FF, REC, PLAY, STOP)

Type:
  • Object
Since:
  • 2.1.1

Methods

<static> getKeyMap() → {Object}

Gets the current key type mapping.

Since:
  • 2.0.0
Returns:

map A set of key/value pairs. The key is a numeric key code, and the value is a corresponding type string.

Type
Object
Example
var keyMap = caph.event.key.getKeyMap();
 keyMap[27] = 'escape';
 
 caph.event.key.setKeyMap(keyMap);

<static> getType(code) → {String}

Gets the mapping type string corresponding to the given key code. If there is no matching type, will return 'unknown'.

Parameters:
Name Type Description
code Number

A numeric key code.

Since:
  • 2.0.0
Returns:

A string which is matched to the numeric code.

Type
String
Example
caph.event.key.setKeyMap({
     27: 'escape'
 });
 
 var escape = caph.event.key.getType(27); // escape === 'escape'
 var unknown = caph.event.key.getType(0); // unknown === 'unknown' 

<static> setKeyMap(map) → {caph.event.key}

Sets the key type mapping. Replace the previous value map with the given value map.

Parameters:
Name Type Description
map Object

A set of key/value pairs. The key is a numeric key code, and the value is a corresponding type string.

Since:
  • 2.0.0
Returns:
Type
caph.event.key
Example
caph.event.key.setKeyMap({
     27: 'escape'
 });