Using "Shift + Click" or "Ctrl + Click" in Triggers

May 25, 2015

Is there a way to require the user to hold down the Shift key or Ctrl key while clicking on something in Articulate Storyline?  I'm trying to create a simulation of selecting multiple items in a list.

I thought of using the "User Presses a Key" trigger to adjust a variable indicating whether or not Shift/Ctrl is held down. It looks like you can only use Shift/Ctrl in combination with other keys in the Trigger Wizard, however.   Any other ideas?

20 Replies
Gary Collins

Well I sort of have this working with javascript but not completely.

I created a button with a normal state and 'ctrl_selected' state.

I also have a variable called 'keypress' initially set to 'false'

I add a trigger to the button to change the state to 'ctrl_selected' if keypress equals true.

Then I add a slide trigger that executes javascript when the timeline starts.

JAVASCRIPT

var player = GetPlayer();

player.addEventListener("keydown", function(event) {
if (event.ctrlKey )
player.SetVar("keypress",true);
});

player.addEventListener("keyup", function(event) {
if (event.ctrlKey )
player.SetVar("keypress",false);
});

This will detect the ctrl key down and change the variable to true so that when the user clicks the button the state will change.

I also want to be able to detect the keyup event so that when they release the ctrl key it will return back to false otherwise they can click more buttons without holding the ctrl key because the variable will be true.

The problem I am having is the keyup function is not being detected.

I am not a javascript expert but this is what I came up with so far when googling javascript.

I will keep trying but hopefully someone else can help out with this to get the keyup event to work.

View online here.

 

Ashley Terwilliger-Pollard

Hi Christodoulos,

Also if you don't have a web server to upload the content to, you could look at using Tempshare.articulate.com which is a free testing platform and the link will stay live for 10 days. Also, you could look at using Amazon S3 as a hosting platform as it does have generous usage limits at a low cost. This article described here how to upload and use Amazon S3. 

Marko Stojkovski
Gary Collins

Carol,

I have updated the file so you can now select and deselect the items.

You can view it here.

And download the source here.

Hello. This is kinda old topic, but I have found it searching through the internet. I need the CTRL function in a software simulation I am currently working on, so these two links are not working. I would really like to see the solution. Thanks

Marko Stojkovski

Hello, me again. Just to let you know that I have finally found a solution for this problem. I am not sure did the quoted links in my post above had the same solution, but here are the links to the solution I came up with:
LinkedIn Article: https://www.linkedin.com/pulse/ctrl-click-select-many-shift-trigger-software-marko-stojkovski?published=t
My webpage post: http://www.enaspot.com/?portfolio=ctrl-click-trigger-select-many-in-software-simulation

 

Nicki Berry

This thread has just helped me out immensely. I have a 'Try it' type module where progression to the next slide in the software simulation is a trigger and Marko's solution works perfectly there. 

The test module though, needs questions rather than triggers as it feeds into a results slide. I want to use the same principle to force users to SHIFT + click (highlight all in a list) but there is no trigger to link the variable to. Any ideas?

This discussion is closed. You can start a new discussion or contact Articulate Support.