[Newbies] Detecting keyboard state / finding older fixes
stan shepherd
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
indistinguishable.
Stan
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
>> doesn't
>> appear to differentiate between a 'real' key down and a repeat. For
>> example
>> :
>>
>> 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:
>>
>> keyStrokes
>> keys
>> do: [:key | key
>> ifNotNil: [(oldKeys includes: key)
>> ifFalse: [Transcript show: 'key added ' , key asString;
>> cr]]].
>> oldKeys do: [:key | key
>> ifNotNil: [(keys includes: key)
>> ifFalse: [Transcript show: 'key removed ' , key asString;
>> cr]]].
>> 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
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>
--
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
mailing list