Created
January 23, 2013 02:45
-
-
Save alexcican/4601414 to your computer and use it in GitHub Desktop.
Snippet for capturing keyboard keys with Javascript (unfinshed)
This file contains hidden or 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).on('keydown', function(e) { | |
if (e.keyCode >= 65 && e.keyCode <= 90) { | |
var char = (e.metaKey ? '⌘-' : '') + String.fromCharCode(e.keyCode) | |
$('#keydown').append('<kbd>' + char + '</kbd>') | |
e.preventDefault(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment