Skip to content

Commit 11265a1

Browse files
author
Mikahil Ilin
committed
Shift key modifier for moving objects
1 parent 3a4a353 commit 11265a1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

js/fui-canvas.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,23 +427,24 @@ const fuiCanvasComponent = {
427427
this.CTX.restore();
428428
},
429429
keyDownHandler(event) {
430-
if (event.isComposing) {
430+
if (event.isComposing || event.target !== document.body) {
431431
return;
432432
}
433433
if (this.currentLayer && Object.values(KEYS).includes(event.keyCode)) {
434434
event.preventDefault();
435+
const shift = event.shiftKey ? 10 : 1;
435436
switch (event.keyCode) {
436437
case KEYS.UP:
437-
this.currentLayer.y -= 1;
438+
this.currentLayer.y -= shift;
438439
break;
439440
case KEYS.DOWN:
440-
this.currentLayer.y += 1;
441+
this.currentLayer.y += shift;
441442
break;
442443
case KEYS.LEFT:
443-
this.currentLayer.x -= 1;
444+
this.currentLayer.x -= shift;
444445
break;
445446
case KEYS.RIGHT:
446-
this.currentLayer.x += 1;
447+
this.currentLayer.x += shift;
447448
break;
448449
default:
449450
break;

0 commit comments

Comments
 (0)