lbry-desktop/src/ui/util/detect-typing.js

14 lines
354 B
JavaScript
Raw Normal View History

// A simple function to detect if a user is typing:
// useful when hanlding shorcut keys.
2019-08-02 08:28:14 +02:00
export default function isUserTyping() {
const activeElement = document.activeElement;
if (activeElement) {
const elementType = activeElement.tagName.toLowerCase();
return elementType === 'input' || elementType === 'textarea';
}
return false;
}