Pressing Anything Other Than ENTER

May 23, 2018

I can set a trigger for advancing to the next slide if a user presses ENTER, but I also want to trigger adding "1" to a variable if they press anything other than ENTER.

3 Replies
Joe Tansengco


If you are comfortable using javascript/jquery, you can easily do this by writing a script that takes all input a user enters except 'Enter', and writes to a variable on keypress. The trick here is to isolate the 'Enter' keypress so that it does not get counted along with the others. You could do something like:

$('#searchbox input').bind('keypress', function(e) {
// Enter key not pressed... Trigger counter to variable...

Or you can try this alternative:

var code = e.keyCode || e.which;
if(code != 13) { //This detects any key presses except the Enter key
//Trigger count }

The basic logic is that if a non-Enter key is pressed, it triggers the count, and does nothing when Enter is detected. 

Hope this helps!



Joe Tansengco


A good place to start would be using the configuration seen below:

Since you're setting the trigger to happen when a 'User presses a key', the javascript gets called up whenever this trigger is activated. As you can see in the screen grab, you can set which javascript is used by clicking on the 'Script' selector option. Now the javascript's job is to detect which key was pressed and then send out a variable count when necessary, or do nothing when it detects that the 'Enter' key was pressed.

It may take a lot of trial and error to get working, but hopefully this points you in the right direction. 



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