YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUI Compressor
  • YUI Doc
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

jafl slideshow nzakas davglass event apipkin io plugin port foxxtrot form jsonp ericf lsmith skinnable widget html5 caridy yui2 rgrove adam overlay filter animation node ajax

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Nav keys (gallery-event-nav-keys) on cdn

    Last Updated: 02/26/10
    + 1 -

    Luke Smith

    YUI Developer

    See 6 more by this user.

    Created: 02/26/10
    Last CDN Push: 03/2/10
    Build Tag: gallery-2010.03.02-18
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    Using the synthetic event API new in 3.1, 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 in two ways, as individual events "up", "down", "left", and "right", as well as a generic "arrow" event. The latter event reports the direction ("up", "down", etc) on the event object in the 'direction' property. So node.on('arrow', function (e) { if (e.direction === "up") { ... } });

    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.

    The supporting version is marked as 3.0, but it requires the new event-synthetic API in 3.1 (or on development head from github prior to the release).

    • Tags:
    • keyboard
    • key
    • synthetic
    • lsmith
    • event
    • accessibility
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    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.

    Code Sample

    <script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2010.03.02-18'
    }).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" ); }
        } );
     
    });

    Forum Posts

    No forum posts for this module.

    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUI Doc
    • YUI Compressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits