Hi I have the following code in my Cesium project and would like to know how I can use other keys other than the characters. Here is what I have at the minute:
function getFlagForKeyCode(keyCode) {
switch (keyCode) {
case 'W'.charCodeAt(0):
return 'moveForward';
case 'S'.charCodeAt(0):
return 'moveBackward';
case 'Q'.charCodeAt(0):
return 'moveUp';
case 'E'.charCodeAt(0):
return 'moveDown';
case 'D'.charCodeAt(0):
return 'moveRight';
case 'A'.charCodeAt(0):
return 'moveLeft';
default:
return undefined;
}
}
I want to be able to use the - and + keys. How can I achieve this?
Up, down, left and right use the arrow keys which are codes 37-40 and the + and - keys are 187 and 189:
function getFlagForKeyCode(keyCode) {
switch (keyCode) {
case 187:
return 'moveForward';
case 189:
return 'moveBackward';
case 38:
return 'moveUp';
case 40:
return 'moveDown';
case 39:
return 'moveRight';
case 37:
return 'moveLeft';
default:
return undefined;
}
}