A Pen by Justin Liu on CodePen.
Created
December 19, 2013 17:42
-
-
Save yutin1987/8043252 to your computer and use it in GitHub Desktop.
A Pen by Justin Liu.
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
<html> | |
<head> | |
</head> | |
<body> | |
</body> | |
</html> |
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
$ () -> | |
keys = [38,38,40,40,37,39,37,39,66,65] | |
key_str = | |
38: '↑' | |
40: '↓' | |
37: '←' | |
39: '→' | |
65: 'A' | |
66: 'B' | |
key_index = 0 | |
tip = '' | |
$('body').keydown(e) -> | |
if keys[key_index] is parseInt(e.keyCode) | |
tip = tip+key_str[keys[key_index]] | |
key_index++ | |
else | |
tip = '' | |
key_index = 0 | |
$('body').text tip | |
if key_index >= keys.length | |
$('body').text 'PASS' | |
key_index = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment