@@ -376,7 +376,7 @@ test('should listen to multiple combinations with modifiers', async () => {
376376 alt : true ,
377377 meta : false ,
378378 mod : false ,
379- useKey : false ,
379+ useKey : true ,
380380 isSequence : false ,
381381 hotkey : 'alt+b' ,
382382 } )
@@ -1055,7 +1055,8 @@ test('should listen to function keys f1-f16', async () => {
10551055 const user = userEvent . setup ( )
10561056 const callback = vi . fn ( )
10571057
1058- renderHook ( ( ) => useHotkeys ( 'f1, f16' , callback ) )
1058+ // Function keys are physical keys — use code-based matching
1059+ renderHook ( ( ) => useHotkeys ( 'f1, f16' , callback , { useKey : false } ) )
10591060
10601061 await user . keyboard ( '[F1]' )
10611062 await user . keyboard ( '[F16]' )
@@ -1128,7 +1129,7 @@ test('should pass keyboard event and hotkey object to callback', async () => {
11281129 alt : false ,
11291130 meta : false ,
11301131 mod : false ,
1131- useKey : false ,
1132+ useKey : true ,
11321133 isSequence : false ,
11331134 hotkey : 'a' ,
11341135 } )
@@ -1150,7 +1151,7 @@ test('should set shift to true in hotkey object if listening to shift', async ()
11501151 alt : false ,
11511152 meta : false ,
11521153 mod : false ,
1153- useKey : false ,
1154+ useKey : true ,
11541155 isSequence : false ,
11551156 hotkey : 'shift+a' ,
11561157 } )
@@ -1172,7 +1173,7 @@ test('should set ctrl to true in hotkey object if listening to ctrl', async () =
11721173 alt : false ,
11731174 meta : false ,
11741175 mod : false ,
1175- useKey : false ,
1176+ useKey : true ,
11761177 isSequence : false ,
11771178 hotkey : 'ctrl+a' ,
11781179 } )
@@ -1194,7 +1195,7 @@ test('should set alt to true in hotkey object if listening to alt', async () =>
11941195 alt : true ,
11951196 meta : false ,
11961197 mod : false ,
1197- useKey : false ,
1198+ useKey : true ,
11981199 isSequence : false ,
11991200 hotkey : 'alt+a' ,
12001201 } )
@@ -1216,7 +1217,7 @@ test('should set mod to true in hotkey object if listening to mod', async () =>
12161217 alt : false ,
12171218 meta : false ,
12181219 mod : true ,
1219- useKey : false ,
1220+ useKey : true ,
12201221 isSequence : false ,
12211222 hotkey : 'mod+a' ,
12221223 } )
@@ -1238,7 +1239,7 @@ test('should set meta to true in hotkey object if listening to meta', async () =
12381239 alt : false ,
12391240 meta : true ,
12401241 mod : false ,
1241- useKey : false ,
1242+ useKey : true ,
12421243 isSequence : false ,
12431244 hotkey : 'meta+a' ,
12441245 } )
@@ -1260,7 +1261,7 @@ test('should set multiple modifiers to true in hotkey object if listening to mul
12601261 ctrl : false ,
12611262 meta : false ,
12621263 mod : true ,
1263- useKey : false ,
1264+ useKey : true ,
12641265 isSequence : false ,
12651266 hotkey : 'mod+shift+a' ,
12661267 } )
@@ -1362,7 +1363,7 @@ test('should call preventDefault option function with hotkey and keyboard event'
13621363 ctrl : false ,
13631364 meta : false ,
13641365 mod : false ,
1365- useKey : false ,
1366+ useKey : true ,
13661367 isSequence : false ,
13671368 hotkey : 'a' ,
13681369 } )
@@ -1597,11 +1598,11 @@ test('Should listen to produced key and not to code', async () => {
15971598 expect ( callback ) . toHaveBeenCalledTimes ( 1 )
15981599} )
15991600
1600- test ( 'Should not check produced key if useKey is not set ' , async ( ) => {
1601+ test ( 'Should not check produced key if useKey is false ' , async ( ) => {
16011602 const user = userEvent . setup ( )
16021603 const callback = vi . fn ( )
16031604
1604- renderHook ( ( ) => useHotkeys ( `=` , callback ) )
1605+ renderHook ( ( ) => useHotkeys ( `=` , callback , { useKey : false } ) )
16051606
16061607 await user . keyboard ( `=` )
16071608
0 commit comments