Forum Discussion
Key press triggers help
Hello,
I have been trying to use the Control key as my trigger because I am creating a simulation of our system. But Storyline 360 won't take it unless it is paired with another key. Which is not what I want. Is there a way around that? Please help.
3 Replies
- NedimCommunity Member
The Ctrl, Shift, and Alt keys are designed as modifier keys. These special keys, when pressed in combination with other keys, trigger specific actions. The only way to detect when the Ctrl key is pressed on its own (without other modifiers) is to use JavaScript. You can write a script that listens for the Ctrl key press event, and when detected, it changes a variable value to true. Once the variable changes, you can trigger an action, such as jumping to the next slide.
- SamHillSuper Hero
Hi IngridCarrer168 I think they might avoid that due to potential conflict with other system and accessibility tool shortcuts. There could be another reason, just a theory.
Here's the JavaScript to do what you want. Just add this to the timeline start trigger.
document.addEventListener("keydown", function(event) { if (event.ctrlKey) { const player = GetPlayer(); const current = player.GetVar("ctrlkey") !== true; // forcing the "ctrlkey" value to change everytime the CTRL key is selected player.SetVar("ctrlkey",current); } });
Attached is an example of implementation that just triggers an animation every time the CTRL key is selected.
- IngridCarrer168Community Member
I tried it, and it works! You are a lifesaver. Thank you so much SamHill 😃