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?
Asked
Active
Viewed 44 times
0
-
1You need this: https://stackoverflow.com/questions/3532053/regular-expression-for-only-characters-a-z-a-z – anemomylos Jul 29 '17 at 17:23
-
2regexp 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
-
1Avoid 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