Skip to content

Instantly share code, notes, and snippets.

@140am
Last active May 3, 2022 16:12
Show Gist options
  • Save 140am/7463028 to your computer and use it in GitHub Desktop.
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
$(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