Detect any key press
Hi,
I am working on OpenSesame with Expyriment back end. I need users to give a description as response. So I need to use entire keyboard. I am collecting key-presses one by one. The code I am using is shown below. It seems like the execution is paused at line 'key, time = my_keyboard.get_key()' until a key is pressed. I need the execution to continue even if there is no key press. That is, in case there is a key press, it should execute the 'if' statement, and if there is no keypress it should continue execution bypassing the 'if'. I need the execution to continue with a return value of 'None' even if there is no key press, and not to pause till a key is pressed.
Another issue i am facing is that if keys are pressed at a higher speed, then few key presses are not detected. I want to collect all key presses even if they are made at a higher rate.
Please give me some guidance regarding these issues.

Comments
Hi,
You need to set the timeout parameter in the get_key() command; e.g.,
my_keyboard.get_key(timeout = 1). This collects a key over the course of 1ms, and thus collects a 'none' for every millisecond that no key was pressed.Then there's still the problem that if people type very very fast, you may lose a keypress or two. Is it necessary that people type as fast as possible? Otherwise you could ask your participants to try to type at a relaxed pace. The 1ms timeout should certainly be able to accommodate normal typing speeds.
Cheers,
Josh
Hi,
The problem of missing keypress was resolved once i switched the back end from xpyriment to legacy. I am collecting responses using keyboard and all keypresses are collected properly. I wanted to add something sort of a 'Next' button to move forward. I created a rectangle and monitored for mouse click in that rectangular region. Mouse clicks are getting detected properly now, but now the key presses are getting missed. The code I am using is shown below.
When I comment the following portion all keypresses get recorded properly.
With above portion included in the code, there is issues with collecting keypresses.
Please help me resolving this issue.