MCPcopy Create free account
hub / github.com/codecombat/codecombat / elementAcceptsKeystrokes

Function elementAcceptsKeystrokes

app/core/application.js:28–36  ·  view source on GitHub ↗
(el)

Source from the content-addressed store, hash-verified

26}
27
28let 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
39if (window.console == null) {

Callers 1

preventBackspaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected