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.)