2019-07-04 06:24:33 +02:00
|
|
|
// 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() {
|
2019-07-04 06:24:33 +02:00
|
|
|
const activeElement = document.activeElement;
|
|
|
|
|
|
|
|
if (activeElement) {
|
|
|
|
const elementType = activeElement.tagName.toLowerCase();
|
|
|
|
return elementType === 'input' || elementType === 'textarea';
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|