AniwatchPlus/utils/helpers.js

25 lines
604 B
JavaScript
Raw Normal View History

var isShiftPressed = false;
var isCtrlPressed = false;
2020-07-29 10:35:57 +02:00
function isHtmlElement(object) {
return object instanceof HTMLElement;
}
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
}