2020-07-29 13:49:05 +02:00
|
|
|
var isShiftPressed = false;
|
|
|
|
var isCtrlPressed = false;
|
|
|
|
|
2020-07-29 10:35:57 +02:00
|
|
|
function isHtmlElement(object) {
|
|
|
|
return object instanceof HTMLElement;
|
2020-07-29 13:49:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('keydown', event => handleKeyDown(event));
|
|
|
|
document.addEventListener('keyup', event => handleKeyUp(event));
|
|
|
|
|
|
|
|
function handleKeyDown(event) {
|
|
|
|
handleKeyToggle(event, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleKeyUp(event) {
|
|
|
|
handleKeyToggle(event, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleKeyToggle(event, isPressed) {
|
|
|
|
if (event.key === 'Shift') {
|
|
|
|
isShiftPressed = isPressed;
|
|
|
|
} else if (event.key === 'Control') {
|
|
|
|
isCtrlPressed = isPressed;
|
|
|
|
}
|
2020-07-29 10:35:57 +02:00
|
|
|
}
|