Luke Smith![]()
Using the synthetic event API, creates custom DOM events for subscribing to keydown that reports a specific keyCode in the event. The end result is something like node.on('enter', function (e) { MyApp.sendData(); e.preventDefault(); });
Arrow key events are presented as individual events "up", "down", "left", and "right". So node.on('left', function (e) { /* left arrow was pressed */ });
These events are mainly to simplify adding keyboard navigation support for accessibility and for rapid prototyping. They also (hopefully) have the effect of making the code a bit more human readable.
Increase or decrease a number in an input using the arrow keys. Bump the value up or down by increments of 10 using the pageUp and down and set it to 0 by hitting escape.
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2011.02.02-21-07'
}).use('gallery-event-nav-keys', function(Y) {
Y.one( "#some-input" ).on( {
up : function () { this.set( "value", this.get( "value" ) + 1 ); },
down : function () { this.set( "value", this.get( "value" ) - 1 ); },
pageUp : function () { this.set( "value", this.get( "value" ) + 10 ); },
pageDown: function () { this.set( "value", this.get( "value" ) - 10 ); },
esc : function () { this.set( "value", "0" ); }
} );
});No forum posts for this module.
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info