Limit repeat Receive Keyboard Button events

Hi,

Node: vuo.keyboard.button2

How would I limit repeated Receive Keyboard Button events to only allow x keyboard events within a time period? For example, how to stop a user from repeatedly hitting a key to start a video playing.

In my use case I have three videos files (01.mpg, 02.mpg, 03.mpg). The video files are selected for playback by hitting the A, B or C key. If I try to trigger the video files too quickly I’ve had instances where the playback glitches and either goes slow or locks up. The video files are short clips encoded to 720p 25fps mpg. The keyboard input will come from a Makey Makey or Arduino Leonardo.

Ideally I would like something like a wait time in seconds between letting the next keyboard button event through.

Here’s a workaround - there’s probably a more efficient way. Pressing the button plays the movie and resets the ‘Allow First Event’ node after 2 seconds which will allow another keypress in 2s, and so on, replaying the video from time 0.

To use it, plug in the video file into the ‘Play Movie’ path and press play. Repeated presses are filtered out before every 2 seconds.Hope this is useful.  

TimedKeyPress_0.vuo (6.52 KB)

1 Like

Hi Marc,

Thanks for the pointer. It didn’t quite work for my use case but I did manage to get it working by adding a Hold Value node. I’m using the Select Latest node to pass the video URL attached to the keyboard button and it seemed that I needed the additional node to create the wait time. I’m testing a 5 second delay to but could safely reduce this down to 2 seconds. The videos don’t lock up now :)

What you can’t see me doing in the video is repetitively hitting the A, B C keys to show the wait time between allowing key presses is working :)  

1 Like

Hi @2bitpunk I feel happy that it helped a bit. Have a great day.