Input handler

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Input handler

Post by SebMcClouth »

I've visited several newsgroups, but neither one of them can really help me.

I need a key handler that can handle single and multiple keys e.g. tab, alt-tab, space, F12, up and down and left and right (arrows). If they are recognized the program has to perform a certain action.

grtz
Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Antoni
Veteran
Posts: 132
Joined: Wed Jun 15, 2005 3:01 pm
Contact:

Post by Antoni »

1.-There are several multiple key handlers around. Here is one of them http://www.qbasicnews.com/abc/showsnipp ... snippet=30
It's an assembler interrupt service routine that hooks to the keyboard interrupt, don't forget to always disable it before exiting the program or DOS will freeze.
It maps the keyboard to an array of 128 integers, using the key scan codes (you have these codes in the QB help). It polls the keyboard in the backgraound, you don't have to worry about this.
AFIR the normal INPUT, INKEY$ can't be used when multikey is active.
If you run a dos box in windows, multikey won't be able to read more than 3 keys at the same time, I don't know why...

2.-You can emulate a multikey in pure basic, if the app is not time critical it will work, and you will not risk craskes. This is at the price of having to poll regularly the keyboard port http://www.ocf.berkeley.edu/~horie/qbmkey.bas
Last edited by Antoni on Wed Aug 03, 2005 3:55 am, edited 1 time in total.
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

Good new for me: I program at a pure dos system. I still find that to be the best way to program.

Thx for the hints.

grtz
Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
User avatar
SebMcClouth
Veteran
Posts: 240
Joined: Fri Apr 29, 2005 2:20 am
Location: Inside the Matrix

Post by SebMcClouth »

I tried sumfin diffrent but I need one more multiple key for the moment.

How can I get Alt-tab to work witht the CHR$?

grtz
Seb
I know why you're here. I know what you've been doing... why you hardly sleep, why you live alone, and why night after night, you sit by your computer...<br>
Unfortunately, no one can be told what Qbinux is. You have to see it for yourself.
Post Reply