Last active
May 3, 2022 16:12
-
-
Save 140am/7463028 to your computer and use it in GitHub Desktop.
Exampel of arrow Key Navigation via Statechart events in JavaScript. from http://stativ.us
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).bind('keydown', function(evt){ | |
var myStatechart = window.myStatechart, kid, | |
keyKey = {'38':'Up', '39': 'Right', '40':'Down', '37': 'Left', '13': 'Enter'}; | |
console.log('Which: ', evt.which); | |
kid = keyKey[evt.which]; | |
if (kid) myStatechart.sendEvent('key'+kid); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment