RectControl.KeyDown
From Real Software Documentation
The user has pressed the Key passed while the RectControl has the focus.
Returns a Boolean. Returning True means that no further processing is to be done with the Key.
Example
The TypeSelection ListBox project is in the Examples folder that ships with Real Studio. It consists of a custom class that is based on the ListBox that has code in the KeyDown event handler. When the user types a key or sequence of keys, this event searches the rows of the listbox for the item with the best match.
The first portion of the method handles kepresses in quick succession. In the provided example, this is used to distinguish between the first two rows that begin with the same letter.
The line of code within the If statement compares the key or keys the user typed to the rows of the listbox until a match is found.
Dim i As Integer
If (ticks-lastKeyPressedAt < 30) Then
lastkeyPressed = lastkeyPressed + key
Else
lastkeyPressed = key
End If
lastKeyPressedAt = ticks
ListIndex = -1
For i = 0 To ListCount-1
If (Lowercase(Left(list(i), Len(lastKeyPressed))) = Lowercase(lastKeyPressed)) Then
listindex = i
Exit For
End If
Next
See Also
Keyboard Module.
