When()

args:

identifier / focusTarget / commandName / undefined: String / HTMLElement, this argument can mean a few different things depending on what methods are called next on the Whenable that When() returns:

  • identifier: a String key identifier used to register one or more keyboard events with IsPressed(), IsReleased(), IsHeldFor() or IsInput()
  • focusTarget (depreciated): either a String id: / class: target string, or an HTMLElement focus target
  • commandName (depreciated): a String command name used for registering a command
  • undefined (depreciated): When() may not be passed an argument, for example when using modes

returns: Whenable

When() is the starting point for everything you will do in When.

Use In Shortcut Chains

Used as a function (with ()), it returns a Whenable that can be used to create a keyboard shortcut:

// here, the argument is an "identifier" used to register a "pressed" event
When('a').Execute(console.log);

Methods

When() also has its own methods that can be accessed to do global actions: