Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keyboard buffer?
#1
Hi,

I was wondering that is there any way to read data from the keyboard buffer? I mean directly from qbasic, without using slow Inkey$

Tnx
IVA LA QBASIC
Reply
#2
INKEY$ IS reading directly from the keyboard buffer, it's pure qbasic and anyways, keyboard buffering is slow. What you want to do is read from the keyboard PORT, which is done by using INP(&H60)
I'd knock on wood, but my desk is particle board.
Reply
#3
That's nice... all works, but it returns only numbers.... I was needing something better for my script lang to program command Inkey$, and if several scripts wanted to have inkey at the same time...well messy
IVA LA QBASIC
Reply
#4
It returns scan codes.
http://webster.cs.ucr.edu/AoA/DOS/pdf/apndxc.pdf

Most of the alphabet can be grabbed by:
chr$(scancode).

1-127 means you're pressing down, and all those keys + 128 = you're releasing the key.
Reply
#5
I guess I'm dumb :oops:
How do I use these numbers? I tryed Chr$(scancode) but it doesn't work.
IVA LA QBASIC
Reply
#6
Well, before I continue, if you want to use an assembly solution like milo sedlack's multikey, you should, as a straight qb solution just doesnt work.

do something like this:

'somewhere in a loop:

x = inp(&H80)
if inp x < 128 then
. . . . buffer(x) = 1
else
. . . . buffer(x-128) = 0
end if

'clear keyboard buffer
def seg=0
poke &H41a, peek (&H41c)
def seg

so buffer(keycode) would have the state
Reply
#7
Quote:How do I use these numbers? I tryed Chr$(scancode) but it doesn't work.

Why do you want to do that anyways? Just use the scancode number directly.

Oh and in case you don't usually do it, you might want to use constants to represent the numbers. Makes for easy debugging in the end. :wink:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)