Skip to content

Commit

Permalink
Use event.code instead of event.key, see phetsims/scenery#1053
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Jun 23, 2021
1 parent 3a4784b commit 3ee0c17
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions js/accessibility/AccessibleNumberSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ const AccessibleNumberSpinner = {
},
keyup: function( event ) {

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

if ( KeyboardUtils.isRangeKey( event.domEvent ) ) {
if ( runningTimerCallbackEvent && key === KeyboardUtils.getKeyDef( runningTimerCallbackEvent ) ) {
if ( runningTimerCallbackEvent && key === KeyboardUtils.getEventCode( runningTimerCallbackEvent ) ) {
self.emitKeyState( event.domEvent, false );
self._callbackTimer.stop( false );
self._callbackTimer.removeCallback( downCallback );
Expand Down
8 changes: 4 additions & 4 deletions js/accessibility/AccessibleValueHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const AccessibleValueHandler = {
// block input event after handling the keydown event
this.blockInput = false;

// @private {Object.<KeyDef, boolean>} - key is range key, value is whether it is down
// @private {Object.<string, boolean>} - key is the event.code for the range key, value is whether it is down
this.rangeKeysDown = {};

// @private - setting to enable/disable rounding to the step size
Expand Down Expand Up @@ -495,7 +495,7 @@ const AccessibleValueHandler = {
*/
handleKeyDown( event ) {
const domEvent = event.domEvent;
const key = KeyboardUtils.getKeyDef( domEvent );
const key = KeyboardUtils.getEventCode( domEvent );
this._shiftKey = domEvent.shiftKey;

// if we receive a keydown event, we shouldn't handle any input events (which should only be provided
Expand Down Expand Up @@ -604,15 +604,15 @@ const AccessibleValueHandler = {
* @param {SceneryEvent} event
*/
handleKeyUp( event ) {
const key = KeyboardUtils.getKeyDef( event.domEvent );
const key = KeyboardUtils.getEventCode( event.domEvent );

// handle case where user tabbed to this input while an arrow key might have been held down
if ( this.allKeysUp() ) {
return;
}

// reset shift key flag when we release it
if ( key === KeyboardUtils.KEY_SHIFT ) {
if ( key === KeyboardUtils.KEY_SHIFT_LEFT ) {
this._shiftKey = false;
}

Expand Down

0 comments on commit 3ee0c17

Please sign in to comment.