| 26 | } |
| 27 | |
| 28 | let elementAcceptsKeystrokes = function (el) { |
| 29 | // http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back |
| 30 | if (el == null) { el = document.activeElement } |
| 31 | const tag = el.tagName.toLowerCase() |
| 32 | const type = el.type != null ? el.type.toLowerCase() : undefined |
| 33 | const textInputTypes = ['text', 'password', 'file', 'number', 'search', 'url', 'tel', 'email', 'date', 'month', 'week', 'time', 'datetimelocal'] |
| 34 | // not radio, checkbox, range, or color |
| 35 | return ((tag === 'textarea') || ((tag === 'input') && Array.from(textInputTypes).includes(type)) || ['', 'true'].includes(el.contentEditable)) && !(el.readOnly || el.disabled) |
| 36 | } |
| 37 | |
| 38 | // IE9 doesn't expose console object unless debugger tools are loaded |
| 39 | if (window.console == null) { |