@@ -8,7 +8,8 @@ export default function useKeyNavigation(containerRef) {
8
8
if (
9
9
! [ "ArrowUp" , "ArrowDown" , "Enter" , "Tab" , "Escape" , " " ] . includes (
10
10
event . key
11
- )
11
+ ) &&
12
+ ! [ "NumpadAdd" , "NumpadSubtract" ] . includes ( event . code )
12
13
) {
13
14
return ;
14
15
}
@@ -29,7 +30,10 @@ export default function useKeyNavigation(containerRef) {
29
30
return ;
30
31
}
31
32
32
- if ( [ "ArrowUp" , "ArrowDown" ] . includes ( event . key ) ) {
33
+ if (
34
+ [ "ArrowUp" , "ArrowDown" ] . includes ( event . key ) ||
35
+ [ "NumpadAdd" , "NumpadSubtract" ] . includes ( event . code )
36
+ ) {
33
37
// Prevent page scrolling.
34
38
event . preventDefault ( ) ;
35
39
// Prevent from opening autocomplete popup.
@@ -81,11 +85,12 @@ export default function useKeyNavigation(containerRef) {
81
85
const index = inputs . findIndex ( ( input ) => event . target === input ) ;
82
86
if ( index === - 1 ) return ;
83
87
const mod = ( n ) => ( n + inputs . length ) % inputs . length ;
84
- if ( event . key === "ArrowUp" ) {
88
+ if ( event . key === "ArrowUp" || event . code === "NumpadSubtract" ) {
85
89
const previousElement = inputs [ mod ( index - 1 ) ] ;
86
90
focusAndSelect ( previousElement ) ;
87
91
} else if (
88
92
event . key === "ArrowDown" ||
93
+ event . code === "NumpadAdd" ||
89
94
( event . target . tagName === "INPUT" && event . key === "Enter" )
90
95
) {
91
96
const nextElement = inputs [ mod ( index + 1 ) ] ;
@@ -103,7 +108,8 @@ export default function useKeyNavigation(containerRef) {
103
108
104
109
function handleKeyDown ( event ) {
105
110
if (
106
- [ "ArrowUp" , "ArrowDown" , "Enter" , " " ] . includes ( event . key ) &&
111
+ ( [ "ArrowUp" , "ArrowDown" , "Enter" , " " ] . includes ( event . key ) ||
112
+ [ "NumpadAdd" , "NumpadSubtract" ] . includes ( event . code ) ) &&
107
113
event . target === document . body
108
114
) {
109
115
// Focus the form if no input is focused and one of the above keys gets pressed.
0 commit comments