Class Index | File Index

Classes


Class glow.events.KeyboardEvent


Extends glow.events.DomEvent.

Defined in: core.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
glow.events.KeyboardEvent(nativeEvent, properties)
Describes a keyboard event.
Field Summary
Field Attributes Field Name and Description
 
key
The key pressed This is a string representing the key pressed.
 
The character entered.
Fields borrowed from class glow.events.DomEvent:
altKey, button, ctrlKey, mouseLeft, mouseTop, nativeEvent, related, shiftKey, source, type, wheelData
Fields borrowed from class glow.events.Event:
attachedTo
Methods borrowed from class glow.events.DomEvent:
stopPropagation
Methods borrowed from class glow.events.Event:
defaultPrevented, preventDefault
Class Detail
glow.events.KeyboardEvent(nativeEvent, properties)
Describes a keyboard event. You don't need to create instances of this class if you're simply listening to events. One will be provided as the first argument in your callback.
Parameters:
{Event} nativeEvent
A native browser event read properties from.
{Object} properties Optional
Properties to add to the Event instance. Each key-value pair in the object will be added to the Event as properties.
Field Detail
key
The key pressed This is a string representing the key pressed. Alphanumeric keys are represented by 0-9 and a-z (always lowercase). Other safe cross-browser values are: Some keys may trigger actions in your browser and operating system, some are not cancelable.
				glow(document).on('keypress', function(event) {
					switch (event.key) {
						case 'up':
							// do stuff
							break;
						case 'down':
							// do stuff
							break;
					}
				});

keyChar
The character entered. This is only available during 'keypress' events. If the user presses shift and 1, event.key will be "1", but event.keyChar will be "!".
				// only allow numbers to be entered into the ageInput field
				glow('#ageInput').on('keypress', function(event) {
					// Convert keyChar to a number and see if we get
					// a valid number back
					return !isNaN( Number(event.keyChar) );
				});

Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jun 14 2010 14:24:09 GMT+0100 (BST)