BackspaceHighjack.js 684 B

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