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 that occurred You don't need to create instances of this class if you're simply listening to events.
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.Event:
defaultPrevented, preventDefault
Class Detail
glow.events.KeyboardEvent(nativeEvent, properties)
Describes a keyboard event that occurred 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 uppercase. Other safe cross-browser values are:
  • backspace
  • tab
  • return
  • shift
  • alt
  • escape
  • space
  • pageup
  • pagedown
  • end
  • home
  • left
  • up
  • right
  • down
  • insert
  • delete
  • ;
  • =
  • -
  • f1
  • f2
  • f3
  • f4
  • f5
  • f6
  • f7
  • f8
  • f9
  • f10
  • f11
  • f12
  • numlock
  • scrolllock
  • pause
  • ,
  • .
  • /
  • [
  • \
  • ]
  • 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) {
    					return !isNaN( Number(event.keyChar) );
    				});

    Documentation generated by JsDoc Toolkit 2.3.2 on Wed Mar 03 2010 14:15:22 GMT-0000 (GMT)