Class: Key

Key

Key represents the mapping between a physical key's name and it's machine code. It contains static references to all known keys, e.x. Key.A - and allows you to map a name or key code to one of those static instances.

new Key(name, code)

Constructs a new instance of Key from a name and a keycode

Parameters:
Name Type Description
name string

The name of the key

code number

The key code for the key

Source:
  • keys.js, line 248

Members

<static> keymap :object

The raw map of key names to key codes. Used internally for some operations.

Type:
  • object
Source:
  • keys.js, line 266

<static> metaKeys :Array

A static collection of all the meta key instances

Type:
  • Array
Source:
  • keys.js, line 389

Methods

<static> fromName(name) → {Key}

Retreive a Key instance associated with the provided name

Parameters:
Name Type Description
name string

The name of the key as can be found in the keymap

Source:
  • keys.js, line 399
Returns:
Type
Key

isMeta() → {boolean}

Return true if the current Key is a meta key

Source:
  • keys.js, line 456
Returns:

true if the Key is one of the meta keys

Type
boolean

isPressed(code) → {boolean}

Determine if the provided key code was pressed

Parameters:
Name Type Description
code number

The key code from e.which

Source:
  • keys.js, line 446
Returns:
Type
boolean