-
-
Save HendrikRoth/e22d89f06f4eee2a240c to your computer and use it in GitHub Desktop.
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
var onKey = (function(){ | |
var keymap = { | |
'enter' : 13, | |
'space' : 31, | |
'tab' : 9, | |
'esc' : 27, | |
'left' : 37, | |
'up' : 38, | |
'right' : 39, | |
'down' : 40 | |
}; | |
return function bind( key, callback ){ | |
if( key in keymap ){ | |
key = keymap[ key ]; | |
} | |
return function handler( e ){ | |
if( e && key === e.keyCode || key === String.fromCharCode( e.keyCode ) ){ | |
callback.call( this, e ); | |
} | |
else { | |
m.redraw.strategy( 'none' ); | |
} | |
}; | |
}; | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment