minor beautification of keyhandling
This commit is contained in:
parent
4622a67f9e
commit
fd8a5a2ce1
1 changed files with 29 additions and 27 deletions
|
|
@ -6,7 +6,7 @@ var ctx;
|
|||
var locationx;
|
||||
var locationy;
|
||||
var autoscale = false;
|
||||
var radius = 1; // the radius of the circle whe put the photo inside
|
||||
var radius = 1; // the radius of the circle where put the photo inside
|
||||
var zoomfactor = 1;
|
||||
var baseCoordZoom;
|
||||
var trX = 0;
|
||||
|
|
@ -100,32 +100,34 @@ function mouseWheel(event) {
|
|||
mouseMove(event);
|
||||
}
|
||||
|
||||
function keyhandler(event) {
|
||||
var keyCode;
|
||||
var doDraw = false;
|
||||
|
||||
document.onkeydown = function(event) {
|
||||
var keyCode;
|
||||
var doDraw = false;
|
||||
if (event == null) {
|
||||
keyCode = window.event.keyCode;
|
||||
} else {
|
||||
keyCode = event.keyCode;
|
||||
}
|
||||
switch (keyCode) {
|
||||
// left
|
||||
case 37:
|
||||
rotation += rotationStep;
|
||||
doDraw = true;
|
||||
break;
|
||||
// right
|
||||
case 39:
|
||||
rotation -= rotationStep;
|
||||
doDraw = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (doDraw) {
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
if (event == null) {
|
||||
keyCode = window.event.keyCode;
|
||||
} else {
|
||||
keyCode = event.keyCode;
|
||||
}
|
||||
switch (keyCode) {
|
||||
// left
|
||||
case 37:
|
||||
rotation += rotationStep;
|
||||
doDraw = true;
|
||||
break;
|
||||
// right
|
||||
case 39:
|
||||
rotation -= rotationStep;
|
||||
doDraw = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (doDraw) {
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
document.onkeypress = keyhandler;
|
||||
document.onkeydown = keyhandler;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue