Skip to content

Commit

Permalink
Renamed KeyboardUtils => KeyboardUtils, see phetsims/tasks#966
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 30, 2019
1 parent 4a40242 commit 812e7b6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
14 changes: 7 additions & 7 deletions js/ComboBoxListBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 ];
Expand All @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions js/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions js/accessibility/AccessibleNumberSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 );

Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
}
},
Expand Down
26 changes: 13 additions & 13 deletions js/accessibility/AccessibleValueHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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
Expand All @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 812e7b6

Please sign in to comment.