The unique hash which represents this key.
The character code of the key.
Whether this key is meant to be used for keypress events rather than keyup and keydown.
The key code of the key.
The character code of the key.
Whether this key requires the Ctrl key held.
Whether this key requires the Alt key held.
Whether this key requires the meta key held.
Whether this key requires the shift key held. It is invalid
to use this parameter if keypress
is true
. When keypress
is
false
, an unspecified value here means false
.
True if any modifiers are turned on for this key. False otherwise. Shift is not considered a modifier for our purposes.
The uniqueness of the return value this method returns is guaranteed only per module instance, which generally translates to "per JavaScript execution context". For instance, if this code is loaded in two different browser pages, the module will be instantiated once per page and the return values for Key objects that were created with the same parameters might differ. So if these two pages communicate with one another they cannot use the return value of this method to identify objects.
A hash value that uniquely identifies the object. The value should be considered to be opaque.
This method compares the key object to an event object. The event object should have been generated for a keyboard event. This method does not check the type of object.
A jQuery or DOM event object.
True if the key object matches the event, false otherwise.
Sets an event object so that it matches this key. If this is not a keypress event, the event type will be set to keydown. The caller can set it to keyup as needed.
A jQuery or DOM event object. This object is modified by the method.
Client code should use the convenience functions provided by this module to create keys rather than use this function directly.
The character code of the key.
Whether this key is meant to be used for keypress events rather than keyup and keydown.
The key code of the key.
The character code of the key.
Whether this key requires the Ctrl key held.
Whether this key requires the Alt key held.
Whether this key requires the meta key held.
Whether this key requires the shift key held. It is invalid
to use this parameter if keypress
is true
. When keypress
is
false
, an unspecified value here means false
.
The key corresponding to the parameters.
Generated using TypeDoc
One and only one instance of a Key object exists per set of parameters used for its construction. So if
a = new Key(1, 2, 3)
andb = new Key(1, 2, 3)
thena === b
is true. The last three parameters are normalized to boolean values, sonew Key(1, 2, 3)
is the same asnew Key(1, 2, 3, false, false, false)
.Key objects should be considered immutable. Modifying them after their creation is likely to cause code to execute erratically.
A note on the handling of the shift key. For key presses, we do not care whether shift was held or not when the key was pressed. It does not matter to us whether the user types the letter A because "Shift-a" was pressed or because the user was in caps lock mode and pressed "a". Conversely,
keydown
andkeyup
events concern themselves with Shift. We do want to distinguish Ctrl-A and Ctrl-Shift-A. (Yes, we use the capital A for both: browsers report that the key "A" was pressed whether Shift was held or not.)