Quote: "BTW: I am not looking for a more efficient way of doing this ... I can do that myself but I just want to know what's wrong with this one ... so please post a solution and not an alternative thanks"
I almost posted an alternative! Anyway, yes speed is a problem but not the real problem. Any key being read from the keyboard or any mousclick will keep repeating until it is released. You knew that. Human beings can't move as fast as the computer can process the keydown/up events so there will be many repeats. You knew that too. If you bring the computer to the human level by forcing the computer to wait for the human release of the key, you are tying your CPU's hands behind it's back.
The computer can still be doing all sorts of things and not waste it's processing power waiting for the release.
You have to let the computer deal with the release at it's own speed. You need to design a toggle switch. The toggle switch will automatically change the state of your test and the computer can go about it's merry business until you change the state again.
the code snippet:
if keystate(28)=1
If fine by itself but will remain 1 until you release it. Everyone already said that. So, you need your own event to change state once when and while keystate(28)=1 for the first flip of the switch. And then change state again for the next flip... and so on
for example:
if keystate(28)=1 and flip=0
flip=1
rem start your counting routine
endif
Get the idea? This will allow the computer to keep doing whatever it wants to do and not be held up waiting for the key release. Maybe you can figure out the way to switch flip back to 0.
This is one example of a toggle. There are easier ways to do this so I'll leave that to you.
Sometimes though, you'll want everything to halt until the key is released - like in an application when you are selecting a menu item or responding to a messagebox. So in those case using WHILE or REPEAT may be ideal. But for a simple start and stop, you'll most likely want to implement a toggle switch.
Enjoy your day.