Page 1 of 1

HELP: hPB with "arrowkey"

Posted: Wed Mar 19, 2008 10:02 am
by ThierryO
Hi everybody,

I am developing a task in which questions are responded with arrowkeys.
But, if an key is pressed twice (or more) for the same question, the first keypress is considered as the reply for the current trial, and the other are memorized and used for the next trials, which, when they are presented, are automatically responded with the previous key presses.

How to take into account the first keypress only (and ignore the others)?

tx,
Thierry

Posted: Wed Mar 19, 2008 1:50 pm
by Janschenkel
Hi Thierry,

Here's a quick-and-dirty script which will only allow you to type a single number per second:

Code: Select all

local sBlockKey

on keyDown pKey
  if sBlockKey then 
    beep
    exit keyDown
  end if
  if pKey is an integer then 
    put true into sBlockKey
    send "UnblockKey" to me in 2 seconds
  end if
  pass keyDown
end keyDown

on UnblockKey
  put false into sBlockKey
end UnblockKey
Hope this helped,

Jan Schenkel.

Posted: Wed Mar 19, 2008 6:21 pm
by ThierryO
Jan,

Thank you for your help. I now use the idea of an unblock handler and replaced a 'wait' with "send" to fix the problem.