Keys

In the modern digital world, keyboard shortcuts or key combinations have become essential tools for increasing efficiency and productivity in a variety of computing environments, whether on desktops, laptops, tablets or even smartphones.

These specific key sequences allow users to quickly execute frequently used commands, actions or functions, bypassing traditional graphical interfaces.

The Keys feature lets you recreate a keyboard user environment.

How to use


The Keys.registerShortcut method associates a boolean Storyline variable with a key combination. The onKeyUp and onKeyDown keyboard events are then listened for: if the registered combination is executed, the value of the variable is swapped.

Key combinations are registered in the main initialisation trigger.

JavaScript
Keys.registerShortcut('CombinaisonID',...touchesListe);

The method accepts :

  • CombinaisonID : an identifier designating the combination.
    A Boolean variable using the identifier as a name must be created in Storyline.

  • keysList : a list of one or more keys that need to be pressed to complete the combination.


Exemple


Let's take an example: we want to use the space bar to pause videos in Storyline.

First, we create a boolean variable alias_pause in Storyline with the default value False. Then add the JavaScript declaration to the main initialisation trigger to register the combination.

JavaScript
Keys.registerShortcut('alias_pause',' ');

Code keys


The Keys feature listens to the KeyboardEvent event interface when a key is pressed, and uses the KeyboardEvent.key value of that key.

To find out the value you are looking for :

  1. publish your module with at least one declaration with at least 2 arguments (a variable name and a key code, even if they are unrelated),
  2. launch the module,
  3. display the debugging console and
  4. press the relevant key.

The KeyboardEvent.key value will be displayed in square brackets in the console.

Let's complete the combination with the correct KeyboardEvent.key values. Then let's go back to the slide where the video is and create the triggers.

Storyline triggers
When 'alias_pause' changes

// Set the media to pause
- Pause video 'Video 1'
    If 'alias_pause' = value 'True'
- Play video 'Vidéo 1'
    If 'alias_pause' = value 'False'

// or set the slide timeline to pause
- Pause timeline on 'this slide'
    If 'alias_pause' = value 'True'
- Resume timeline on 'this slide'
    If 'alias_pause' = value 'False'