UP | ||
LEFT | DOWN | RIGHT |
<script src="keys.js" type="text/javascript"></script>And add key detection to the body tag
<body onkeydown="keydown(event)" onkeyup="keyup(event)">The script (by default) is designed to be used with a game and sets 5 variables, moveleft, movedown, moveup, moveright, spacedown to true or false depending on wether or not the key is pressed. It can easily be adapted to any use though.