Created
February 4, 2015 18:59
-
-
Save noir-neo/1557ffba47a1295839f0 to your computer and use it in GitHub Desktop.
ハッカーになるためにはタイピングが早くないといけないらしい…
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
| /* | |
| * http://hackersbar.net/recruit.html | |
| */ | |
| // これ美しくないんだが文字からキーコード変換ってできないの | |
| // 自分でキーコード表の連想配列作るしか無いか? | |
| var type = [{'shiftKey':true,'keyCode':72}, | |
| {'shiftKey':false,'keyCode':65}, | |
| {'shiftKey':false,'keyCode':67}, | |
| {'shiftKey':false,'keyCode':75}, | |
| {'shiftKey':false,'keyCode':69}, | |
| {'shiftKey':false,'keyCode':82}, | |
| {'shiftKey':false,'keyCode':83}, | |
| {'shiftKey':false,'keyCode':32}, | |
| {'shiftKey':true,'keyCode':66}, | |
| {'shiftKey':false,'keyCode':65}, | |
| {'shiftKey':false,'keyCode':82} | |
| ];//'Hackers Bar'; | |
| function fireKey(i) { | |
| var eventObj = document.createEvent("Events"); | |
| eventObj.initEvent("keydown", true, true); | |
| eventObj.which = type[i]['keyCode']; | |
| eventObj.keyCode = type[i]['keyCode']; | |
| eventObj.shiftKey = type[i]['shiftKey']; | |
| document.dispatchEvent(eventObj); | |
| if (i<type.length-1) { | |
| setTimeout(function() { | |
| fireKey(++i); | |
| }, 1100/type.length); | |
| } | |
| } | |
| fireKey(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment