Skip to content

Commit

Permalink
simplify usages of keydown input listener, phetsims/scenery#1445 phet…
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Oct 21, 2022
1 parent 15ea99e commit 3e880bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions js/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import optionize from '../../phet-core/js/optionize.js';
import StrictOmit from '../../phet-core/js/types/StrictOmit.js';
import StringUtils from '../../phetcommon/js/util/StringUtils.js';
import CloseButton from '../../scenery-phet/js/buttons/CloseButton.js';
import { AlignBox, FocusManager, FullScreen, HBox, KeyboardUtils, Node, PDOMPeer, PDOMUtils, SceneryEvent, TColor, VBox } from '../../scenery/js/imports.js';
import { AlignBox, FocusManager, FullScreen, HBox, KeyboardUtils, Node, PDOMPeer, PDOMUtils, TColor, TInputListener, VBox } from '../../scenery/js/imports.js';
import TSoundPlayer from '../../tambo/js/TSoundPlayer.js';
import generalCloseSoundPlayer from '../../tambo/js/shared-sound-players/generalCloseSoundPlayer.js';
import generalOpenSoundPlayer from '../../tambo/js/shared-sound-players/generalOpenSoundPlayer.js';
Expand Down Expand Up @@ -405,8 +405,8 @@ export default class Dialog extends Popupable( Panel, 1 ) {
}

// pdom - close the dialog when pressing "escape"
const escapeListener = {
keydown: ( event: SceneryEvent ) => {
const escapeListener: TInputListener = {
keydown: event => {
const domEvent = event.domEvent; // {DOMEvent|null}

if ( KeyboardUtils.isKeyEvent( event.domEvent, KeyboardUtils.KEY_ESCAPE ) ) {
Expand Down
6 changes: 3 additions & 3 deletions js/accessibility/AccessibleNumberSpinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const AccessibleNumberSpinner = <SuperType extends Constructor>( Type: SuperType

// handle all accessible event input
const accessibleInputListener: TInputListener = {
keydown: ( event: SceneryEvent<KeyboardEvent> ) => {
keydown: event => {
if ( ( this as unknown as Node ).enabledProperty.get() ) {

// check for relevant keys here
Expand Down Expand Up @@ -133,7 +133,7 @@ const AccessibleNumberSpinner = <SuperType extends Constructor>( Type: SuperType
}
}
},
keyup: ( event: SceneryEvent<KeyboardEvent> ) => {
keyup: event => {

const key = KeyboardUtils.getEventCode( event.domEvent );

Expand All @@ -150,7 +150,7 @@ const AccessibleNumberSpinner = <SuperType extends Constructor>( Type: SuperType
this.handleKeyUp( event );
}
},
blur: ( event: SceneryEvent<FocusEvent> ) => {
blur: event => {

// if a key is currently down when focus leaves the spinner, stop callbacks and emit that the
// key is up
Expand Down

0 comments on commit 3e880bb

Please sign in to comment.