Gregory Kornblum
Gregory Kornblum

Reputation: 175

How to read keyboard state in Smalltalk (Squeak) without delays

In my last homework they want me to code a game, controlled by keyboard. Part of the game is to press a key and keep holding it.

I use keyDown method to track keyboard events. And what is happening, is that after first event (when i read a single key pressing) there is an approximately half second delay, before the other chars start coming. Same delay as if in a text box you hold "a", after the first char there is a gap of half second.

Where can i tweak that? It really busts the game...

Upvotes: 0

Views: 324

Answers (1)

Amos M. Carpenter
Amos M. Carpenter

Reputation: 4958

I don't think this is an issue with reading the keyboard state in Squeak (or any programming language, for that matter), but an issue with what keyboard signals the operating system sends.

In Windows, you'll want to go to Control Panel > Keyboard > Speed tab, and tweak the "Repeat delay" setting:

Windows keyboard settings

In Linux, I think you need to use the xset or kbdrate command. I'm sure there's something equivalent in Macs.

Having said that, I don't understand why you need to read the OS's keystrokes. Shouldn't you be reading keyDown, and then assuming that that key stays pressed until you get the keyUp event? I would've thought you'd be interested in the keyboard state rather than the individual characters "arriving".

Upvotes: 3

Related Questions