I am working on key mapping. The problem is that when I press the TAB button down it navigates to the next input field.
TAB has key of 9 and
DOWN has key of 40
But, what is the JavaScript key code to go to the previous input field (SHIFT + TAB)?
What I want is to go to next link; what is keycode or code for the previous link?
Please help. Thanks.
Your question asks for they keycode for shift+tab, but you want to detect the up key? Peter, the keyCode 16 is for the Shift key.
key 13 keycode is for ENTER key.
the keyCode=49 for a space.
The enter key is typically located to the right of the 3 and . keys on the lower right of the numeric keypad, while the return key is situated on the right edge of the main alphanumeric portion of the keyboard.
There's no "keycode", it's a separate property on the event object, like this:
if(event.shiftKey && event.keyCode == 9) {
//shift was down when tab was pressed
}
e.keyCode
has been deprecated for sometime. Use "e.key" KeyboardEvent.key instead.
Usage:
e.shiftKey && e.key === 'Tab'
Example:
function clicked(e) {
if (e.shiftKey && e.key === 'Tab') {
// Do whatever, like e.target.previousElementSibling.focus();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With