First time here? Check out the FAQ!

In a Tool is there a way of telling when a key is pressed?

0 votes

I've seen a few examples in Tools of using LastCharacterTyped but is there a way of detecting when a (computer keyboard) key is down? For instance if I want to use a key press as a gate rather than just a trigger I want to detect the key down and possibly key up events. 

I saw in another Q&A answer mention of "KymaWindowSensor shiftDown" to detect the state of the shift key. Is there a similar expression for detecting other keys?

asked Jul 29 in Capytalk & Smalltalk by alan-jackson (Virtuoso) (11,060 points)

1 Answer

0 votes
Unfortunately, Smalltalk tracks the up/down state of only the Control, Shift, Command, and Caps Lock keys and none of the other keys.
answered Jul 29 by ssc (Savant) (93,380 points)
That's a shame. I can't poll either can I, unless there's a "no current key press" state.