Page 1 of 1

Auto-repeating key presses

Posted: Sat Nov 08, 2008 8:22 pm
by bonbon
I'm using "on rawKeyDown" in a database app to trap the PageUp, PageDown, Ctrl-Home and Ctrl-End keyboard presses for navigation through the db, so that the user can press these keys instead of using a menu item or a screen button (if they want to).

The only problem is that if a tired & emotional user holds down either the PageDown or PageUp key without releasing it for a few seconds, the key press messages get stacked up, and when the user finally takes his finger off the key, the app will continue scrolling through the db for quite a while.

Is there a way of increasing the time interval between auto-repeats for keyboard presses ? I've got a feeling this is probably an OS setting, but if anyone has any ideas, please let me know.

Code: Select all

on rawKeyDown theKeyNumber
-- handle PgUp, PgDn, Ctrl-Home & Ctrl-End keys
   put the hilitedLine of field gGrid into tLineNo
   put the number of lines of field gGrid into tTotalLines

   if theKeyNumber is 65365 and the controlKey is up and tLineNo > 1 then -- PageUp
      send "mouseUp" to button "btnPrev"
   else if theKeyNumber is 65366 and the controlKey is up and tLineNo < tTotalLines then -- PageDown
      send "mouseUp" to button "btnNext"
   else if theKeyNumber is 65360 and the controlKey is down then -- Ctrl-Home
      send "mouseUp" to button "btnFirst"
   else if theKeyNumber is 65367 and the controlKey is down then -- Ctrl-End
      send "mouseUp" to button "btnLast"
   else
      pass rawKeyDown -- don't forget this!
   end if
   
end rawKeyDown
Thanks.

Posted: Sat Nov 08, 2008 9:00 pm
by bn
Hi bonbon,
at the end of the mouseUp script, if you put

Code: Select all

 get flushevents "autoKey"
then it terminates the pending rawkeydown messages so it should not go on forever (works for me)
regards
bernd

Posted: Sun Nov 09, 2008 12:23 pm
by bonbon
Hi bernd,

Thanks for that. I had a play with it, and substituted "keyDown" for "autoKey", and it works a treat.

Cheers,
bonbon