Skip to content

Commit

Permalink
doc improvements for Hotkey and hotkeyManager, see #1621
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Apr 26, 2024
1 parent 2804d6a commit 390c8df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 24 additions & 2 deletions js/input/Hotkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,28 @@
* 1. Added to globalHotkeyRegistry (to be available regardless of keyboard focus)
* 2. Added to a node's inputListeners (to be available only when that node is part of the focused trail)
*
* For example:
*
* globalHotkeyRegistry.add( new Hotkey( {
* key: 'y',
* fire: () => console.log( 'fire: y' )
* } ) );
*
* myNode.addInputListener( {
* hotkeys: [
* new Hotkey( {
* key: 'x',
* fire: () => console.log( 'fire: x' )
* } )
* ]
* } );
*
* Also supports modifier keys that must be pressed in addition to the Key. See options for a description of how
* they behave.
*
* Hotkeys are managed by hotkeyManager, which determines which hotkeys are active based on the globalHotkeyRegistry
* and what Node has focus. See that class for information about how hotkeys work.
*
* @author Jesse Greenberg (PhET Interactive Simulations)
* @author Jonathan Olson <[email protected]>
*/
Expand All @@ -20,8 +42,8 @@ import CallbackTimer from '../../../axon/js/CallbackTimer.js';
export type HotkeyFireOnHoldTiming = 'browser' | 'custom';

type SelfOptions = {
// The key that should be pressed to trigger the hotkey (in fireOnDown:true mode) or released to trigger the hotkey (in
// fireOnDown:false mode).
// The key that should be pressed to trigger the hotkey (in fireOnDown:true mode) or released to trigger the hotkey
// (in fireOnDown:false mode).
key: EnglishKey;

// A set of modifier keys that:
Expand Down
1 change: 0 additions & 1 deletion js/input/hotkeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
* The set of enabled hotkeys determines the set of modifier keys that are considered "active" (in addition to
* ctrl/alt/meta/shift, which are always included).
*
*
* @author Jesse Greenberg (PhET Interactive Simulations)
* @author Jonathan Olson <[email protected]>
*/
Expand Down

0 comments on commit 390c8df

Please sign in to comment.