BBC BASIC for Windows
General >> General Board >> Detecting simultaneous key presses http://bb4w.conforums.com/index.cgi?board=general&action=display&num=1276541101 Detecting simultaneous key presses
Post by Danny72 on Jun 14th, 2010, 6:45pm
Hello everyone
Could someone let me know how to detect, for example if the letter j and letter f is pressed at the same time?
thanks,
Danny
Re: Detecting simultaneous key presses
Post by admin on Jun 14th, 2010, 9:47pm
Could someone let me know how to detect, for example if the letter j and letter f is pressed at the same time?
Like this:
Code:
IF INKEY(-70) AND INKEY(-68) THEN
(the various INKEY codes are in the manual, or right-click on INKEY in the editor and select What's This?).
Beware that the test will work even if your window doesn't have 'focus' which can occasionally be inconvenient. If so there is code in the manual for checking for input focus:
Also be aware that you cannot reliably test for more than two keys pressed at the same time (it may sometimes work for three, or even four, keys but it depends on the keys and it depends on the keyboard!).
Richard.
Re: Detecting simultaneous key presses
Post by JonR on Jun 15th, 2010, 5:25pm
To help with loooking up the INKEY codes you can use the INKEY application on my web site that shows the code for whatever key is currently pressed.