@@ -46,7 +46,7 @@ export class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<
4646 options ?: Partial < EventHandlerOptions > ,
4747 ) : this;
4848
49- on ( ...args : any [ ] ) {
49+ on ( ...args : unknown [ ] ) {
5050 const { modifiers, key, handler, options} = this . _normalizeInputs ( ...args ) ;
5151
5252 this . configs . push ( {
@@ -59,8 +59,8 @@ export class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<
5959 return this ;
6060 }
6161
62- private _normalizeInputs ( ...args : any [ ] ) {
63- const withModifiers = Array . isArray ( args [ 0 ] ) || args [ 0 ] in Modifier ;
62+ private _normalizeInputs ( ...args : unknown [ ] ) {
63+ const withModifiers = Array . isArray ( args [ 0 ] ) || ( args [ 0 ] as string ) in Modifier ;
6464 const modifiers = withModifiers ? args [ 0 ] : Modifier . None ;
6565 const key = withModifiers ? args [ 1 ] : args [ 0 ] ;
6666 const handler = withModifiers ? args [ 2 ] : args [ 1 ] ;
@@ -80,7 +80,8 @@ export class KeyboardEventManager<T extends KeyboardEvent> extends EventManager<
8080 modifiers : ModifierInputs ,
8181 options ?: Partial < EventHandlerOptions > ,
8282 ) : boolean {
83- if ( ! hasModifiers ( event , modifiers ) ) {
83+ // In some cases the `key` may be undefined, despite the types saying otherwise. See #33359.
84+ if ( event . key == null || ! hasModifiers ( event , modifiers ) ) {
8485 return false ;
8586 }
8687
0 commit comments