[futurebasic] Re: [FB] Re:[FBII] Checking the keyboard

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2001 : Group Archive : Group : All Groups

From: Jay Reeve <jktr@...>
Date: Sun, 7 Jan 01 22:00:40 -0600
Craig,

>The problem I was having is that you need to do a bit test on 
>each byte of the kb record. As it turns out I discovered that the 
>zeroth (I had to use this... from earlier list postings) bit is the 
>'X' key. Thus if no key pressed or 'X' key pressed would both return 
>zero. 
I think this is mistaken. The 'zeroth' bit is actually the high bit, or 
left-most bit at the address, so if the X key is down, PEEK(@kb) should 
be 128, and FN BITTST(#@kb,0) _should_ return 1.

>Here is my solution to the problem. Note that the kb record is 
>a global as I use the GETKEYS call in other places of my App.
>
>Local FN IsKeyDown
>Dim K
>K=0:CALL GETKEYS(kb)
>FOR t=0 to 127          'Step through each bit of the record
>if FN BITTST(#@kb,t)>0 then K=1
>NEXT t
>END FN=K
>
>    Here I'm not looking for any specific key pressed, but checking 
>for any key pressed. Thanks again for all the responses. Even though 
>no one had a solution it stopped me from chasing my tail looking for 
>another answer. I had reserved my solution looking for a more elegant 
>one. Sometimes it's just whatever will work!

If you just want to know when a key (any key) is pressed, you could use 
this:

Local FN IsAnyKeyDown
Dim K,t
K=0:CALL GETKEYS(kb)
for t = 0 to sizeof(kb) - 1 step 4
if [@kb + t] then K = 1: exit for
NEXT t
END FN=K

 0"0
 =J= a  y
  "