diff --git a/Canvas.js b/Canvas.js index 442fde11c..ceb602a3c 100644 --- a/Canvas.js +++ b/Canvas.js @@ -186,20 +186,36 @@ function newCanvas () { } function onKeyDown (event) { - if (event.shiftKey === true && event.code === 'ArrowUp') { + if (event.altKey === true && event.code === 'ArrowUp') { thisObject.cockpitSpace.toTop() } - if (event.shiftKey === true && event.code === 'ArrowDown') { + if (event.altKey === true && event.code === 'ArrowDown') { thisObject.cockpitSpace.toBottom() } - if (event.keyCode === 37) { - alert('Left key pressed') + if (event.shiftKey === true && event.code === 'ArrowLeft') { + alert('charts to the Left') } - if (event.keyCode === 39) { - alert('Rigth key pressed') + if (event.shiftKey === true && event.code === 'ArrowRight') { + alert('charts to the Rigth') + } + + if (event.ctrlKey === true && event.code === 'ArrowLeft') { + canvas.floatingSpace.oneScreenLeft() + } + + if (event.ctrlKey === true && event.code === 'ArrowRight') { + canvas.floatingSpace.oneScreenRight() + } + + if (event.ctrlKey === true && event.code === 'ArrowUp') { + canvas.floatingSpace.oneScreenUp() + } + + if (event.ctrlKey === true && event.code === 'ArrowDown') { + canvas.floatingSpace.oneScreenDown() } } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index e6a5d4cd3..2bf3e12c8 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -13,6 +13,10 @@ function newFloatingSpace () { strategyPartConstructor: undefined, noteSets: undefined, container: undefined, + oneScreenUp: oneScreenUp, + oneScreenDown: oneScreenDown, + oneScreenLeft: oneScreenLeft, + oneScreenRight: oneScreenRight, fitIntoVisibleArea: fitIntoVisibleArea, isThisPointVisible: isThisPointVisible, makeVisible: makeVisible, @@ -41,6 +45,8 @@ function newFloatingSpace () { thisObject.container.frame.position.y = browserCanvas.height / 2 - thisObject.container.frame.height / 2 let visible = false + + const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 50 return thisObject function finalize () { @@ -93,6 +99,42 @@ function newFloatingSpace () { return returnPoint } + function oneScreenUp () { + let displaceVector = { + x: 0, + y: browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 + } + + thisObject.container.displace(displaceVector) + } + + function oneScreenDown () { + let displaceVector = { + x: 0, + y: -browserCanvas.height * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100 + } + + thisObject.container.displace(displaceVector) + } + + function oneScreenLeft () { + let displaceVector = { + x: browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100, + y: 0 + } + + thisObject.container.displace(displaceVector) + } + + function oneScreenRight () { + let displaceVector = { + x: -browserCanvas.width * PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT / 100, + y: 0 + } + + thisObject.container.displace(displaceVector) + } + function isThisPointVisible (point) { if (point.x > browserCanvas.width) { return false