Может кто-нибудь сказать мне, что происходит?Моя консоль не выдает никаких исключений.
function onKeyDown(){
var e = event.keyCode;
//if (e==87 /*w*/){
up = true;
throw('up');
//}
if (e==65 /*a*/){
left = true;
}
if (e==83 /*s*/){
down = true;
}
if (e==68 /*d*/){
right = true;
}
}
function onKeyUp(){
var e = event.keyCode;
//if (e==87 /*w*/){
up = false;
throw('up');
//}
if (e==65 /*a*/){
left = false;
}
if (e==83 /*s*/){
down = false;
}
if (e==68 /*d*/){
right = false;
}
}
Okay, so that was the javascript, and this is the html:
<body>
<input id="ss" type="button" value="start/stop" />
<div id="container" style="border:1px solid; cursor:none; width:480px; height:320px;">
<canvas id="canvas" width="480" height="320" onkeyup="onKeyUp();" onkeydown="onKeydown();">
Canvas not displaying.
</canvas>
</div>
</body>
Edit: current code:
window.onload = function () {init ();};
function init(){
initSettings();
initImages();
document.getElementById('canvas').onkeydown = function(event) {
var e = event.keyCode;
//if (e==87 /*w*/){
up = true;
throw('up');
//}
if (e==65 /*a*/){
left = true;
}
if (e==83 /*s*/){
down = true;
}
if (e==68 /*d*/){
right = true;
}
}