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

Function preventBackspace

app/core/application.js:19–26  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

17// Prevent Ctrl/Cmd + [ / ], P, S
18const ctrlDefaultPrevented = [219, 221, 80, 83]
19const preventBackspace = function (event) {
20 if ((event.keyCode === 8) && !elementAcceptsKeystrokes(event.srcElement || event.target)) {
21 return event.preventDefault()
22 } else if ((event.ctrlKey || event.metaKey) && !event.altKey && Array.from(ctrlDefaultPrevented).includes(event.keyCode)) {
23 console.debug('Prevented keystroke', key, event)
24 return event.preventDefault()
25 }
26}
27
28let elementAcceptsKeystrokes = function (el) {
29 // http://stackoverflow.com/questions/1495219/how-can-i-prevent-the-backspace-key-from-navigating-back

Callers

nothing calls this directly

Calls 1

elementAcceptsKeystrokesFunction · 0.85

Tested by

no test coverage detected