From 812e7b6d9123a7b506b1f837b98c26d5e62ecd6b Mon Sep 17 00:00:00 2001 From: samreid Date: Mon, 30 Dec 2019 09:29:11 -0700 Subject: [PATCH] Renamed KeyboardUtils => KeyboardUtils, see https://github.com/phetsims/tasks/issues/966 --- js/ComboBoxListBox.js | 14 +++++------ js/Dialog.js | 6 ++--- js/accessibility/AccessibleNumberSpinner.js | 10 ++++---- js/accessibility/AccessibleValueHandler.js | 26 ++++++++++----------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/js/ComboBoxListBox.js b/js/ComboBoxListBox.js index 274f26b9..acd18d41 100644 --- a/js/ComboBoxListBox.js +++ b/js/ComboBoxListBox.js @@ -12,7 +12,7 @@ define( require => { const Action = require( 'AXON/Action' ); const ComboBoxListItemNode = require( 'SUN/ComboBoxListItemNode' ); const EventType = require( 'TANDEM/EventType' ); - const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); + const KeyboardUtils = require( 'SCENERY/accessibility/KeyboardUtils' ); const merge = require( 'PHET_CORE/merge' ); const Panel = require( 'SUN/Panel' ); const SceneryEvent = require( 'SCENERY/input/SceneryEvent' ); @@ -91,7 +91,7 @@ define( require => { // Handle keyup on each item in the list box, for a11y. //TODO sun#447, scenery#931 we're using keyup because keydown fires continuously keyup: event => { - if ( KeyboardUtil.KEY_ENTER === event.domEvent.keyCode || KeyboardUtil.KEY_SPACE === event.domEvent.keyCode ) { + if ( KeyboardUtils.KEY_ENTER === event.domEvent.keyCode || KeyboardUtils.KEY_SPACE === event.domEvent.keyCode ) { fireAction.execute( event ); focusButtonCallback(); } @@ -167,16 +167,16 @@ define( require => { // Handle keydown keydown: event => { const keyCode = event.domEvent.keyCode; - if ( keyCode === KeyboardUtil.KEY_ESCAPE || keyCode === KeyboardUtil.KEY_TAB ) { + if ( keyCode === KeyboardUtils.KEY_ESCAPE || keyCode === KeyboardUtils.KEY_TAB ) { // Escape and Tab hide the list box and return focus to the button hideListBoxCallback(); focusButtonCallback(); } - else if ( keyCode === KeyboardUtil.KEY_DOWN_ARROW || keyCode === KeyboardUtil.KEY_UP_ARROW ) { + else if ( keyCode === KeyboardUtils.KEY_DOWN_ARROW || keyCode === KeyboardUtils.KEY_UP_ARROW ) { // Up/down arrow keys move the focus between items in the list box - const direction = ( keyCode === KeyboardUtil.KEY_DOWN_ARROW ) ? 1 : -1; + const direction = ( keyCode === KeyboardUtils.KEY_DOWN_ARROW ) ? 1 : -1; for ( let i = 0; i < listItemNodes.length; i++ ) { if ( this.focusedItemNode === listItemNodes[ i ] ) { const nextListItemNode = listItemNodes[ i + direction ]; @@ -190,11 +190,11 @@ define( require => { } } } - else if ( keyCode === KeyboardUtil.KEY_HOME ) { + else if ( keyCode === KeyboardUtils.KEY_HOME ) { this.focusedItemNode = listItemNodes[ 0 ]; this.focusedItemNode.focus(); } - else if ( keyCode === KeyboardUtil.KEY_END ) { + else if ( keyCode === KeyboardUtils.KEY_END ) { this.focusedItemNode = listItemNodes[ listItemNodes.length - 1 ]; this.focusedItemNode.focus(); } diff --git a/js/Dialog.js b/js/Dialog.js index 0df6d982..35c00ee0 100644 --- a/js/Dialog.js +++ b/js/Dialog.js @@ -21,7 +21,7 @@ define( require => { const FullScreen = require( 'SCENERY/util/FullScreen' ); const HBox = require( 'SCENERY/nodes/HBox' ); const inherit = require( 'PHET_CORE/inherit' ); - const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); + const KeyboardUtils = require( 'SCENERY/accessibility/KeyboardUtils' ); const merge = require( 'PHET_CORE/merge' ); const Panel = require( 'SUN/Panel' ); const Path = require( 'SCENERY/nodes/Path' ); @@ -340,12 +340,12 @@ define( require => { keydown: event => { const domEvent = event.domEvent; - if ( domEvent.keyCode === KeyboardUtil.KEY_ESCAPE ) { + if ( domEvent.keyCode === KeyboardUtils.KEY_ESCAPE ) { domEvent.preventDefault(); this.hide(); this.focusActiveElement(); } - else if ( domEvent.keyCode === KeyboardUtil.KEY_TAB && FullScreen.isFullScreen() ) { + else if ( domEvent.keyCode === KeyboardUtils.KEY_TAB && FullScreen.isFullScreen() ) { // prevent a particular bug in Windows 7/8.1 Firefox where focus gets trapped in the document // when the navigation bar is hidden and there is only one focusable element in the DOM diff --git a/js/accessibility/AccessibleNumberSpinner.js b/js/accessibility/AccessibleNumberSpinner.js index e9b2aba0..05fc20b4 100644 --- a/js/accessibility/AccessibleNumberSpinner.js +++ b/js/accessibility/AccessibleNumberSpinner.js @@ -30,7 +30,7 @@ define( require => { const Emitter = require( 'AXON/Emitter' ); const extend = require( 'PHET_CORE/extend' ); const inheritance = require( 'PHET_CORE/inheritance' ); - const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); + const KeyboardUtils = require( 'SCENERY/accessibility/KeyboardUtils' ); const merge = require( 'PHET_CORE/merge' ); const Node = require( 'SCENERY/nodes/Node' ); const sun = require( 'SUN/sun' ); @@ -106,7 +106,7 @@ define( require => { if ( enabledProperty.get() ) { // check for relevant keys here - if ( KeyboardUtil.isRangeKey( event.domEvent.keyCode ) ) { + if ( KeyboardUtils.isRangeKey( event.domEvent.keyCode ) ) { if ( !self._callbackTimer.isRunning() ) { self.accessibleNumberSpinnerHandleKeyDown( event ); @@ -119,7 +119,7 @@ define( require => { } }, keyup: function( event ) { - if ( KeyboardUtil.isRangeKey( event.domEvent.keyCode ) ) { + if ( KeyboardUtils.isRangeKey( event.domEvent.keyCode ) ) { if ( event.domEvent.keyCode === runningTimerCallbackKeyCode ) { self.emitKeyState( event.domEvent.keyCode, false ); self._callbackTimer.stop( false ); @@ -184,10 +184,10 @@ define( require => { * @param {boolean} isDown - whether or not event was triggered from down or up keys */ emitKeyState: function( keyCode, isDown ) { - if ( keyCode === KeyboardUtil.KEY_UP_ARROW || keyCode === KeyboardUtil.KEY_RIGHT_ARROW ) { + if ( keyCode === KeyboardUtils.KEY_UP_ARROW || keyCode === KeyboardUtils.KEY_RIGHT_ARROW ) { this.incrementDownEmitter.emit( isDown ); } - else if ( keyCode === KeyboardUtil.KEY_DOWN_ARROW || keyCode === KeyboardUtil.KEY_LEFT_ARROW ) { + else if ( keyCode === KeyboardUtils.KEY_DOWN_ARROW || keyCode === KeyboardUtils.KEY_LEFT_ARROW ) { this.decrementDownEmitter.emit( isDown ); } }, diff --git a/js/accessibility/AccessibleValueHandler.js b/js/accessibility/AccessibleValueHandler.js index fd6c4dc0..963d196d 100644 --- a/js/accessibility/AccessibleValueHandler.js +++ b/js/accessibility/AccessibleValueHandler.js @@ -22,7 +22,7 @@ define( require => { // modules const extend = require( 'PHET_CORE/extend' ); const inheritance = require( 'PHET_CORE/inheritance' ); - const KeyboardUtil = require( 'SCENERY/accessibility/KeyboardUtil' ); + const KeyboardUtils = require( 'SCENERY/accessibility/KeyboardUtils' ); const merge = require( 'PHET_CORE/merge' ); const Node = require( 'SCENERY/nodes/Node' ); const Property = require( 'AXON/Property' ); @@ -451,7 +451,7 @@ define( require => { if ( this._enabledProperty.get() ) { // Prevent default so browser doesn't change input value automatically - if ( KeyboardUtil.isRangeKey( code ) ) { + if ( KeyboardUtils.isRangeKey( code ) ) { domEvent.preventDefault(); // this should do the same thing as this.a11yInputHandled for "change" and "input" // if this is the first keydown this is the start of the drag interaction @@ -463,39 +463,39 @@ define( require => { this.rangeKeysDown[ code ] = true; let newValue = this._valueProperty.get(); - if ( code === KeyboardUtil.KEY_END || code === KeyboardUtil.KEY_HOME ) { + if ( code === KeyboardUtils.KEY_END || code === KeyboardUtils.KEY_HOME ) { // on 'end' and 'home' snap to max and min of enabled range respectively (this is typical browser // behavior for sliders) - if ( code === KeyboardUtil.KEY_END ) { + if ( code === KeyboardUtils.KEY_END ) { newValue = this._rangeProperty.get().max; } - else if ( code === KeyboardUtil.KEY_HOME ) { + else if ( code === KeyboardUtils.KEY_HOME ) { newValue = this._rangeProperty.get().min; } } else { let stepSize; - if ( code === KeyboardUtil.KEY_PAGE_UP || code === KeyboardUtil.KEY_PAGE_DOWN ) { + if ( code === KeyboardUtils.KEY_PAGE_UP || code === KeyboardUtils.KEY_PAGE_DOWN ) { // on page up and page down, the default step size is 1/10 of the range (this is typical browser behavior) stepSize = this.pageKeyboardStep; - if ( code === KeyboardUtil.KEY_PAGE_UP ) { + if ( code === KeyboardUtils.KEY_PAGE_UP ) { newValue = this._valueProperty.get() + stepSize; } - else if ( code === KeyboardUtil.KEY_PAGE_DOWN ) { + else if ( code === KeyboardUtils.KEY_PAGE_DOWN ) { newValue = this._valueProperty.get() - stepSize; } } - else if ( KeyboardUtil.isArrowKey( code ) ) { + else if ( KeyboardUtils.isArrowKey( code ) ) { // if the shift key is pressed down, modify the step size (this is atypical browser behavior for sliders) stepSize = domEvent.shiftKey ? this.shiftKeyboardStep : this.keyboardStep; - if ( code === KeyboardUtil.KEY_RIGHT_ARROW || code === KeyboardUtil.KEY_UP_ARROW ) { + if ( code === KeyboardUtils.KEY_RIGHT_ARROW || code === KeyboardUtils.KEY_UP_ARROW ) { newValue = this._valueProperty.get() + stepSize; } - else if ( code === KeyboardUtil.KEY_LEFT_ARROW || code === KeyboardUtil.KEY_DOWN_ARROW ) { + else if ( code === KeyboardUtils.KEY_LEFT_ARROW || code === KeyboardUtils.KEY_DOWN_ARROW ) { newValue = this._valueProperty.get() - stepSize; } @@ -530,12 +530,12 @@ define( require => { } // reset shift key flag when we release it - if ( domEvent.keyCode === KeyboardUtil.KEY_SHIFT ) { + if ( domEvent.keyCode === KeyboardUtils.KEY_SHIFT ) { this._shiftKey = false; } if ( this._enabledProperty.get() ) { - if ( KeyboardUtil.isRangeKey( domEvent.keyCode ) ) { + if ( KeyboardUtils.isRangeKey( domEvent.keyCode ) ) { this.rangeKeysDown[ domEvent.keyCode ] = false; // when all range keys are released, we are done dragging