0

I would like to make it so that a function runs only when the user types any key from a-z. Would I need to use a different method other than onkeypress?

  • 1
    You need this: https://stackoverflow.com/questions/3532053/regular-expression-for-only-characters-a-z-a-z – anemomylos Jul 29 '17 at 17:23
  • 2
    regexp is overkill, you can check just key codes. As a-z follows each other, you can check if keycode is in range – insider Jul 29 '17 at 17:24
  • so I should store event.keycode into lets say variable x, then check if the value of x is within range? – Kieran Kuhn Jul 29 '17 at 17:30
  • 1
    Avoid using keycodes. It is being depreciated. https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode – Gowtham Shiva Jul 29 '17 at 17:32

0 Answers0