Skip to content

Commit

Permalink
use KeyboardEvent.code instead of deprecated KeyboardEvent.keyCode, p…
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Jan 27, 2023
1 parent 566b389 commit 2a3b27f
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions js/DynamicStringTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ import { localizedStrings } from '../../chipper/js/getStringModule.js';
import Utils from '../../dot/js/Utils.js';
import joist from './joist.js';

// keyCodes
const LEFT_ARROW = 37;
const UP_ARROW = 38;
const RIGHT_ARROW = 39;
const DOWN_ARROW = 40;
const SPACE_BAR = 32;

const INITIAL_STRING_FACTOR = 1;
const MAX_STRING_FACTOR = 8; // so that the sim and/or browser doesn't lock up when strings get excessively long
const MIN_STRING_FACTOR = 0.01;
Expand Down Expand Up @@ -49,19 +42,19 @@ export default class DynamicStringTest {
* Handles a KeyboardEvent.
*/
public handleEvent( event: KeyboardEvent ): void {
if ( event.keyCode === LEFT_ARROW ) {
if ( event.code === 'ArrowLeft' ) {
this.halveStrings();
}
else if ( event.keyCode === RIGHT_ARROW ) {
else if ( event.code === 'ArrowRight' ) {
this.doubleStrings();
}
else if ( event.keyCode === UP_ARROW ) {
else if ( event.code === 'ArrowUp' ) {
this.setStride( this.stride + 1 );
}
else if ( event.keyCode === DOWN_ARROW ) {
else if ( event.code === 'ArrowDown' ) {
this.setStride( this.stride - 1 );
}
else if ( event.keyCode === SPACE_BAR ) {
else if ( event.code === 'Space' ) {
this.reset();
}
}
Expand Down

0 comments on commit 2a3b27f

Please sign in to comment.