metanohi-misc-subsites/nohix/key.js

29 lines
496 B
JavaScript

window.onload = function() {
UP = 38
RIGHT = 39
DOWN = 40
LEFT = 37
document.onkeydown = keydown
document.onkeyup = keyup
keys = []
}
function getkeycode(e) {
var keycode
if (window.event) keycode = window.event.keyCode
else if (e) keycode = e.which
else keycode = 0
return keycode
}
function keydown(e) {
var keycode = getkeycode(e)
keys[keycode] = true
document.title = keycode
}
function keyup(e) {
var keycode = getkeycode(e)
keys[keycode] = true
}