A Screen mode INKEY
Posted: Tue Jan 11, 2005 3:56 pm
<B>Requirement:</B> It would be nice to have for Screen Modes the sort of functionality that INKEY() offers for Console Mode. This would allow one to trap keyboard characters whilst running say, a timer, as illustrated in the following thread:-
viewtopic.php?t=13625
<B>Suggested function:</B> KeyboardTest()
<B>Platform:</B> Windows and Linux
<B>Return:</B> True/False
Without experience, it is difficult to know what ExamineKeyboard() is doing. It would appear to flush out the keyboard buffer and then take a snapshot of the current pressed keys (if any). The problem seems to be that a following KeyboardInkey command, if used as a true/false test, does destroy buffer content as one would expect. Thus it does not seem possible to KeyboardInkey again immediately, this time with the intention of grabbing the character. This is indicated in the thread mentioned above.
This proposal then, is for a similar routine to KeyboardInkey that does not destroy the keyboard buffer. It would thus allow:-
Now one can route depending on whether achar$ is the telltale or a character.[/code]
viewtopic.php?t=13625
<B>Suggested function:</B> KeyboardTest()
<B>Platform:</B> Windows and Linux
<B>Return:</B> True/False
Without experience, it is difficult to know what ExamineKeyboard() is doing. It would appear to flush out the keyboard buffer and then take a snapshot of the current pressed keys (if any). The problem seems to be that a following KeyboardInkey command, if used as a true/false test, does destroy buffer content as one would expect. Thus it does not seem possible to KeyboardInkey again immediately, this time with the intention of grabbing the character. This is indicated in the thread mentioned above.
This proposal then, is for a similar routine to KeyboardInkey that does not destroy the keyboard buffer. It would thus allow:-
Code: Select all
Repeat
achar$=""
If KeyboardTest()
achar$=KeyboardInkey()
Else
Test the timer
If Timeout
achar$="Telltale"
EndIf
EndIf
Until achar$<>""