Single, double or triple press a key


Hi together,

I would like to switch pages based on a single, double or triple press on a single key (T).
The logic is quite clear to me, but I don’t know how to realize in Axure

  1. page up key event with condition key pressed = T
  2. wait 500ms for second key up event --> if not switch to Page A
  3. page up key event with condition key pressed = T
  4. wait 500ms for third key up event --> if not switch to Page B
  5. page up key event with condition key pressed = T --> switch to page C

Is that possible to realize in Axure?

Thanks in advance


Hmm, interesting.

One option is to use a ‘checker’ object to drive the condition as you need a temporary store of the key presses. Could probably hide the widget.


ah yes I remember this mechanism with moving an object to call something like a function.
Although this is not exactly what I wanted (third tap doesn’t react instantly --> also waiting 500ms) this shows how I can do it.

Thanks a lot


Using a basic “Wait 500 ms” seems like it should be pretty simple and straightforward, but it tends to not work so well. For timing things like this, I’ve found it is more reliable and powerful to use a dedicated timer, which is best practice in any programming language. Unfortunately, Axure doesn’t have a built-in timer available, but you can make one with a repeating dynamic panel. The Wait action is not a true timer and cannot be controlled or canceled after it fires. Although in this example, the result is to open a different page, so most potential failures should be avoided, and when I tested it, it did seem to work pretty well.

@wsnowsf , I kind of like the idea of testing the text length of a widget. For me, incrementing a global variable is more straightforward. On the other hand, the text widget does provide good user feedback for how many ‘T’ presses have been registered (and some programmers just don’t like global variables.) But given your method, since the “Checker” object is testing itself, you can just use [[This.length]] or use the built in “length of widget value” condition without needing to assign a local variable; it’s quicker, and I think the code is easier to read. Also, I would argue any key presses more than 3 should be the same as 3 presses, rather than be ignored. Since @iamable replied that the third keypress should immediately load a page, I’ll assume this is the intention.

Here is a demo file:
Multiple Key Presses.rp (118.1 KB)

I included three different methods, although they all use the same basic approach.

  • On Page 1, I implemented the method from @wsnowsf

  • On Page 2, I implemented a dedicated timer function, in the form of a dynamic panel

    • The Page Key Up event still tests if the ‘T’ key has been pressed (and released)
    • There is a dynamic panel named, “Timer” with 2 empty states. On a successful key press Timer is set to stop repeating (in case it is already repeatedly changing states; meaning a second or later keypress.) Then it sets Timer to repeatedly change states every 500 ms. In this way, each keypress should be guaranteed to get 500 ms of “lag time” rather than relying on multiple Wait actions, which can collide timing-wise.
    • Then, the global variable, “keyT” is incremented, providing a count of how many keypresses
    • When Timer changes states, it tests the value of keyT and opens the appropriate page.
  • On Page 3, I show a way to immediately open Page C on the third ‘T’ keypress.

    • I added a conditional case to the Page Key Up event that first tests if ‘T’ key pressed AND the keypress count is 2 or greater (meaning it is the third keypress of ‘T’ because the count has not yet been incremented) …and it simply opens Page C right away.
    • This same approach can easily be used with the method from @wsnowsf
    • ( I added a “Feedback” widget to show the letter T with keypresses. This is only to mimic what is shown on Page 1 and for demonstration purposes only.)