BackspaceHighjack.js 602 B

1234567891011121314151617181920
  1. /* eslint-disable
  2. max-len,
  3. */
  4. // TODO: This file was created by bulk-decaffeinate.
  5. // Fix any style issues and re-enable lint.
  6. /*
  7. * decaffeinate suggestions:
  8. * DS102: Remove unnecessary code created because of implicit returns
  9. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  10. */
  11. const rx = /INPUT|SELECT|TEXTAREA/i
  12. export default $(document).bind('keydown keypress', function (e) {
  13. if (e.which === 8) {
  14. // 8 == backspace
  15. if (!rx.test(e.target.tagName) || e.target.disabled || e.target.readOnly) {
  16. return e.preventDefault()
  17. }
  18. }
  19. })