Prototype – Keyboard Shortcuts

Event.observe(window, 'load', function() {

    Event.observe(document, 'keypress', function(e){

        var code;

        if (!e) var e = window.event;

        if (e.keyCode) code = e.keyCode;

        else if (e.which) code = e.which;

        var character = String.fromCharCode(code);

        alert('Character was ' + character);

    });

});
This entry was posted in Prototype / Scriptaculous. Bookmark the permalink.

Leave a Reply