shortcut key not working ctrl + shift + numpad1
up vote
0
down vote
favorite
I need to implement a simple functionality on keyboard shortcut but combination with 'shift' key not work :( .
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.key) {
case '1':
// something
break;
}
}
}
javascript
add a comment |
up vote
0
down vote
favorite
I need to implement a simple functionality on keyboard shortcut but combination with 'shift' key not work :( .
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.key) {
case '1':
// something
break;
}
}
}
javascript
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+1 is also !
– 0.sh
Nov 19 at 12:14
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Check this
– Zohir Salak
Nov 19 at 19:52
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to implement a simple functionality on keyboard shortcut but combination with 'shift' key not work :( .
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.key) {
case '1':
// something
break;
}
}
}
javascript
I need to implement a simple functionality on keyboard shortcut but combination with 'shift' key not work :( .
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.key) {
case '1':
// something
break;
}
}
}
javascript
javascript
asked Nov 19 at 12:11


Filip Laurentiu
114113
114113
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+1 is also !
– 0.sh
Nov 19 at 12:14
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Check this
– Zohir Salak
Nov 19 at 19:52
add a comment |
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+1 is also !
– 0.sh
Nov 19 at 12:14
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Check this
– Zohir Salak
Nov 19 at 19:52
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+1 is also !
– 0.sh
Nov 19 at 12:14
shift+1 is also !
– 0.sh
Nov 19 at 12:14
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Check this
– Zohir Salak
Nov 19 at 19:52
Check this
– Zohir Salak
Nov 19 at 19:52
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
The key code switches to an exclamation point because SHIFT
is being held. Changing the case in your switch to '!'
from '1'
is a possible solution. However you may be using a numpad. I would recommend avoiding the key in this scenario and just getting the event.code
.
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.code) {
case 'Digit1':
alert()
break;
}
}
}
I hope this helps.
add a comment |
up vote
0
down vote
When you are pressing Shift
, the event.key
will be the character that was pressed. In your case when you press Shift + 1
it will be !
.
One possible solution would be to use event.code
property.
For numpad it will give Digit1
, Digit2
, etc.
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
add a comment |
up vote
0
down vote
if (event.ctrlKey && event.code === 'Numpad1')
this works
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The key code switches to an exclamation point because SHIFT
is being held. Changing the case in your switch to '!'
from '1'
is a possible solution. However you may be using a numpad. I would recommend avoiding the key in this scenario and just getting the event.code
.
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.code) {
case 'Digit1':
alert()
break;
}
}
}
I hope this helps.
add a comment |
up vote
1
down vote
accepted
The key code switches to an exclamation point because SHIFT
is being held. Changing the case in your switch to '!'
from '1'
is a possible solution. However you may be using a numpad. I would recommend avoiding the key in this scenario and just getting the event.code
.
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.code) {
case 'Digit1':
alert()
break;
}
}
}
I hope this helps.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The key code switches to an exclamation point because SHIFT
is being held. Changing the case in your switch to '!'
from '1'
is a possible solution. However you may be using a numpad. I would recommend avoiding the key in this scenario and just getting the event.code
.
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.code) {
case 'Digit1':
alert()
break;
}
}
}
I hope this helps.
The key code switches to an exclamation point because SHIFT
is being held. Changing the case in your switch to '!'
from '1'
is a possible solution. However you may be using a numpad. I would recommend avoiding the key in this scenario and just getting the event.code
.
window.onkeydown = (event) => {
if (event.ctrlKey && event.shiftKey) {
switch (event.code) {
case 'Digit1':
alert()
break;
}
}
}
I hope this helps.
edited Nov 19 at 19:46
answered Nov 19 at 19:17


Jesse
2,30211331
2,30211331
add a comment |
add a comment |
up vote
0
down vote
When you are pressing Shift
, the event.key
will be the character that was pressed. In your case when you press Shift + 1
it will be !
.
One possible solution would be to use event.code
property.
For numpad it will give Digit1
, Digit2
, etc.
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
add a comment |
up vote
0
down vote
When you are pressing Shift
, the event.key
will be the character that was pressed. In your case when you press Shift + 1
it will be !
.
One possible solution would be to use event.code
property.
For numpad it will give Digit1
, Digit2
, etc.
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
add a comment |
up vote
0
down vote
up vote
0
down vote
When you are pressing Shift
, the event.key
will be the character that was pressed. In your case when you press Shift + 1
it will be !
.
One possible solution would be to use event.code
property.
For numpad it will give Digit1
, Digit2
, etc.
When you are pressing Shift
, the event.key
will be the character that was pressed. In your case when you press Shift + 1
it will be !
.
One possible solution would be to use event.code
property.
For numpad it will give Digit1
, Digit2
, etc.
answered Nov 19 at 12:19
Daniil Andreyevich Baunov
1,022526
1,022526
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
add a comment |
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
No, numpad1, not the normal 1 (the numbers key in the right side of the keyboards. Numbers only if NumLock is turned on).
– Chayim Friedman
Nov 19 at 12:21
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
I also try this, KeyCode for numpad1 is 97, but after I press ctrl+shift + (any numpad number ) the 'shift' press event still fire.
– Filip Laurentiu
Nov 19 at 12:24
add a comment |
up vote
0
down vote
if (event.ctrlKey && event.code === 'Numpad1')
this works
add a comment |
up vote
0
down vote
if (event.ctrlKey && event.code === 'Numpad1')
this works
add a comment |
up vote
0
down vote
up vote
0
down vote
if (event.ctrlKey && event.code === 'Numpad1')
this works
if (event.ctrlKey && event.code === 'Numpad1')
this works
answered 2 days ago


Filip Laurentiu
114113
114113
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374380%2fshortcut-key-not-working-ctrl-shift-numpad1%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
shift+numpad1 isn't a number, it's an End key...
– Chayim Friedman
Nov 19 at 12:13
shift+1 is also !
– 0.sh
Nov 19 at 12:14
how to make this combination work ? ctrl+shif+numpad1
– Filip Laurentiu
Nov 19 at 12:16
Possible duplicate of How to detect if multiple keys are pressed at once using JavaScript?
– Ram Segev
Nov 19 at 12:17
Check this
– Zohir Salak
Nov 19 at 19:52