From 3b8218e8f78bcea7c1b1ce1e06a68a9c0e292363 Mon Sep 17 00:00:00 2001 From: Jesse Date: Thu, 25 Apr 2024 10:37:03 -0400 Subject: [PATCH] Update usages of KeyboardListener and KeyboardDragListener after changes from https://github.com/phetsims/scenery/issues/1570 --- js/intro/view/EFACIntroScreenView.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/js/intro/view/EFACIntroScreenView.js b/js/intro/view/EFACIntroScreenView.js index ebaea842..74c79faf 100644 --- a/js/intro/view/EFACIntroScreenView.js +++ b/js/intro/view/EFACIntroScreenView.js @@ -290,13 +290,12 @@ class EFACIntroScreenView extends ScreenView { up: leftHeaterCoolerUpInputAction } ) ); - leftHeaterCoolerNode.addInputListener( new KeyboardListener( { - keys: EnglishStringKeyUtils.RANGE_KEYS, - listenerFireTrigger: 'both', - callback: event => event.type === 'keydown' ? - leftHeaterCoolerDownInputAction() : - leftHeaterCoolerUpInputAction() - } ) ); + + const leftKeyboardListener = new KeyboardListener( { keys: EnglishStringKeyUtils.RANGE_KEYS } ); + leftHeaterCoolerNode.addInputListener( leftKeyboardListener ); + leftKeyboardListener.isPressedProperty.link( pressed => { + pressed ? leftHeaterCoolerDownInputAction() : leftHeaterCoolerUpInputAction(); + } ); const rightHeaterCoolerDownInputAction = () => { @@ -316,14 +315,11 @@ class EFACIntroScreenView extends ScreenView { up: rightHeaterCoolerUpInputAction } ) ); - // listen to keyboard events on the right heater-cooler - rightHeaterCoolerNode.addInputListener( new KeyboardListener( { - keys: EnglishStringKeyUtils.RANGE_KEYS, - listenerFireTrigger: 'both', - callback: event => event.type === 'keydown' ? - rightHeaterCoolerDownInputAction() : - rightHeaterCoolerUpInputAction() - } ) ); + const rightKeyboardListener = new KeyboardListener( { keys: EnglishStringKeyUtils.RANGE_KEYS } ); + rightHeaterCoolerNode.addInputListener( rightKeyboardListener ); + rightKeyboardListener.isPressedProperty.link( pressed => { + pressed ? rightHeaterCoolerDownInputAction() : rightHeaterCoolerUpInputAction(); + } ); rightBurnerBounds = model.rightBurner.getBounds(); }