lbry-desktop/ui/util/detect-typing.js
2019-11-11 13:27:29 -05:00

14 lines
355 B
JavaScript

// A simple function to detect if a user is typing:
// useful when handling shortcut keys.
export default function isUserTyping() {
const activeElement = document.activeElement;
if (activeElement) {
const elementType = activeElement.tagName.toLowerCase();
return elementType === 'input' || elementType === 'textarea';
}
return false;
}