From 983d2f1c1a2ace1faa799542eb25aeb60c92f82d Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 26 Mar 2024 10:17:59 -0400 Subject: [PATCH] inspectKeyboardListeners is hidden behind an assertion, see https://github.com/phetsims/scenery/issues/1570 --- js/input/Input.ts | 22 +++++++++++++--------- js/listeners/KeyboardListener.ts | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/js/input/Input.ts b/js/input/Input.ts index 284302b40..92ab712a4 100644 --- a/js/input/Input.ts +++ b/js/input/Input.ts @@ -794,17 +794,21 @@ export default class Input extends PhetioObject { sceneryLog && sceneryLog.Input && sceneryLog.Input( `keydown(${Input.debugText( null, context.domEvent )});` ); sceneryLog && sceneryLog.Input && sceneryLog.push(); - // Look for all global KeyboardListeners that are on Nodes that can receive input events. We will inspect - // this list for overlapping keys. - const keyboardListeners: KeyboardListener[] = []; - this.recursiveScanForGlobalKeyboardListeners( this.rootNode, keyboardListeners ); - - // Also add any local KeyboardListeners along the trail. const trail = this.getPDOMEventTrail( context.domEvent, 'keydown' ); - trail && this.scanTrailForKeyboardListeners( trail, keyboardListeners ); - // Inspect listeners for overlapping keys. - KeyboardListener.inspectKeyboardListeners( keyboardListeners, context.domEvent ); + if ( assert ) { + + // Look for all global KeyboardListeners that are on Nodes that can receive input events. We will inspect + // this list for overlapping keys. + const keyboardListeners: KeyboardListener[] = []; + this.recursiveScanForGlobalKeyboardListeners( this.rootNode, keyboardListeners ); + + // Also add any local KeyboardListeners along the trail. + trail && this.scanTrailForKeyboardListeners( trail, keyboardListeners ); + + // Inspect listeners for overlapping keys. + KeyboardListener.inspectKeyboardListeners( keyboardListeners ); + } this.dispatchGlobalEvent( 'globalkeydown', context, true ); diff --git a/js/listeners/KeyboardListener.ts b/js/listeners/KeyboardListener.ts index 0fd386ceb..dac7e89f7 100644 --- a/js/listeners/KeyboardListener.ts +++ b/js/listeners/KeyboardListener.ts @@ -644,7 +644,7 @@ class KeyboardListener extends EnabledComp * - 'error': If any two listeners use the same keys, an error will be thrown. * - 'allow': All key overlaps are allowed. */ - public static inspectKeyboardListeners( keyboardListeners: KeyboardListener[], event: KeyboardEvent ): void { + public static inspectKeyboardListeners( keyboardListeners: KeyboardListener[] ): void { // Collect KeyGroups with their listeners so can easily look up the listener when iterating through used keys. const naturalKeysWithListener = keyboardListeners.reduce( ( accumulator: KeyGroupWithListener[], listener: KeyboardListener ) => {