Prevent a key pressed, to repeat its characters?

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
Peter@multidesk.se
Posts: 107
Joined: Fri Oct 14, 2011 6:53 am

Prevent a key pressed, to repeat its characters?

Post by Peter@multidesk.se » Wed Feb 22, 2017 12:28 pm

I need to prevent the user to keep a button pressed down and thereby gaining more clicks registered than was intended.

Does anyone have any suggestions on how to do this?

Thanks in advance

Peter
/*Whats all the fuss with c# ?*/

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2259
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Prevent a key pressed, to repeat its characters?

Post by jmburnod » Wed Feb 22, 2017 1:28 pm

Hi Peter,

I use this:

Code: Select all

local sStarTime
on opencard
      put the milliseconds into sStarTime 
end opencard

on mouseUp
   put the milliseconds into tTime
   if tTime > sStarTime +500 then
      beep
   else
      -- do your stuff
   end if
   put the milliseconds into sStarTime
end mouseUp
Best regards
Jean-Marc

Peter@multidesk.se
Posts: 107
Joined: Fri Oct 14, 2011 6:53 am

Re: Prevent a key pressed, to repeat its characters?

Post by Peter@multidesk.se » Wed Feb 22, 2017 1:52 pm

Thanks, but I forgot to mention that it is the keyboard buttons, and not mouse click, I need to handle

I use the keyDown message, and that messages will continue to loop as long as the button is pressed, and that is what I want to prevent.

/Peter
/*Whats all the fuss with c# ?*/

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2259
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Prevent a key pressed, to repeat its characters?

Post by jmburnod » Wed Feb 22, 2017 1:57 pm

What about this:

Code: Select all

on rawkeydown pKey
   put the milliseconds into tTime
   if tTime > sStarTime +500 then
      put the milliseconds into sStarTime
      pass rawkeydown --or do your stuff
   else
      --
   end if
   put the milliseconds into sStarTime
end rawkeydown

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5625
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Prevent a key pressed, to repeat its characters?

Post by dunbarx » Wed Feb 22, 2017 4:23 pm

Peter.

Make sure you include Jean-Marc's earlier openCard handler if you use his second suggestion.

Craig Newman

Post Reply

Return to “Mac OS”