new Combo(key, meta)
Creates a new Combo from a key code and array of meta key codes
Parameters:
Name | Type | Description |
---|---|---|
key |
Key | The primary Key for this Combo. |
meta |
array | An array of meta Keys needed for this Combo to be activated. {optional} |
- Source:
- keys.js, line 481
Example
var combo = new Combo(Key.A, [ Key.CTRL, Key.SHIFT ]);
Methods
-
<static> deserialize(serialized) → {object}
-
Deserialize a Combo object from a JSON string.
Parameters:
Name Type Description serialized
string A serialized Combo object (JSON string)
- Source:
- keys.js, line 581
Returns:
- The deserialized Combo as a regular object
- Type
- object
-
<static> fromEvent(e) → {Combo}
-
Given a keypress event, create a Combo that represents the set of pressed keys
Parameters:
Name Type Description e
Event The keypress event (could be keyup, keydown, or keypress)
- Source:
- keys.js, line 660
Returns:
- Type
- Combo
-
<static> fromObject(obj) → {Combo}
-
Create a Combo from an arbitrary object, primarily meant to be used in conjunction with Bindings.deserialize to properly reify a serialized Combo object. Called directly from Combo.deserialize for this reason as well.
Parameters:
Name Type Description obj
object The anonymous object to create a Combo instance from.
- Source:
- keys.js, line 639
Returns:
- Type
- Combo
-
<static> fromString(str) → {Combo}
-
Reverse of toString, you should get the original combo if you call Combo.fromString(combo.toString()). Useful for converting text inputs with Combo.toString() populated values back into actual Combo objects.
Parameters:
Name Type Description str
string A string which represents a valid Combo
- Source:
- keys.js, line 684
Returns:
- Type
- Combo
-
clone() → {Combo}
-
Deep clone this Combo instance.
- Source:
- keys.js, line 598
Returns:
- Type
- Combo
-
eq(combo) → {boolean}
-
Determine if this Combo is exactly equivalent to another Combo
Parameters:
Name Type Description combo
Combo The Combo to compare
- Source:
- keys.js, line 716
Returns:
- Type
- boolean
-
isMatch() → {boolean}
-
A looser version of equality checking. Whereas
eq
checks for strict value equality,isMatch
checks for equality of intent. Does the user really care if the Combo is not strictly equal even if the same keys are pressed? No.isMatch
is used when matching the Combo generated from a keypress event to Combos stored as keybindings, which might be equal in intent, but not equal in the strictest sense.- Source:
- keys.js, line 742
Returns:
- Type
- boolean
-
metaKeys() → {array}
-
Get this Combo's meta keys as an array of Key instances
- Source:
- keys.js, line 779
Returns:
An array of Key
- Type
- array
-
serialize() → {string}
-
Serialize the Combo for persistance or transport.
- Source:
- keys.js, line 568
Returns:
The Combo as a JSON string
- Type
- string
-
toString() → {string}
-
Pretty print the Combo
- Source:
- keys.js, line 552
Returns:
A string representation of the Combo
- Type
- string