[Newbies] Detecting keyboard state / finding older fixes
squeak414 at free.fr
Fri Mar 7 16:53:14 UTC 2008
I am indeed on Linux. I have a feeling that Windows was the same (coding in
Java). That is, in the programming language a real key down and a repeat are
Bert Freudenberg wrote:
> On Mar 7, 2008, at 14:54 , stan shepherd wrote:
>> Where I was confused is that checking if the key is pressed already
>> appear to differentiate between a 'real' key down and a repeat. For
>> keyDown: anEvent
>> (keys includes: anEvent keyValue)
>> ifTrue: [Transcript show: 'skipped ' , anEvent asString; cr]
>> ifFalse: [keys add: anEvent keyValue. "
>> Transcript show: 'key down ' , anEvent asString; cr.
>> self changed]
>> always takes the 'key down' branch, even for key held down.
>> Was this what you meant?
> Yes. The code above works as expected on Mac OS X, printing
> "skipped..." for auto-repeats.
>> On the other hand, looping over this in a thread:
>> do: [:key | key
>> ifNotNil: [(oldKeys includes: key)
>> ifFalse: [Transcript show: 'key added ' , key asString;
>> oldKeys do: [:key | key
>> ifNotNil: [(keys includes: key)
>> ifFalse: [Transcript show: 'key removed ' , key asString;
>> oldKeys := keys copy.
>> has the desired effect of only showing real key moves.
>> Is this over complicating things?
> It indeed sounds overly complicated, unless your platform forces you
> to resort to such things. Are you on Linux by chance?
> - Bert -
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
View this message in context: http://www.nabble.com/Detecting-keyboard-state---finding-older-fixes-tp15779144p15900698.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
More information about the Beginners