[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

>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 
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
>FOR t=0 to 127          'Step through each bit of the record
>if FN BITTST(#@kb,t)>0 then K=1
>    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 

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

 =J= a  y