Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple keys at once

Status
Not open for further replies.

Sandmann

Programmer
Mar 12, 2001
13
US
Question 1:

I'm making a 2 player game. Can someone tell me how I can make the keyboard recognize two simultaneous keys HELD down at one time?

For example, let's say I have two counters, one that displays how many times the "F" key has been pressed and another counter displaying how many times the "K" key has been pressed. I want to be able to make it so that if both "K" and "F" are both HELD down, that both counters will rise. (Normally, using basic INKEY$, only the last key pressed will register.)

Second question:

I have a program that asks for a key to be pressed at the end of a long list of commands. To be specific, it's an RPG. Let's say, for example, I'm walking around on the map screen and I'm holding the down arrow. When I enter battle, as soon as my fighting options come up, the cursor is already scrolled down to the bottom of the list of commands.

Fight
Magic
Special
> Item

I know this is because it stores up a list of all the keys I press and it keeps using them even after I stop pressing the key.
Is there a way that I can have the program not store up a list of key presses? So that it doesn't take any input from the keyboard until the option is displayed on the screen?

Any help with these questions would be great. (Especially the first one)
 
Just after you enter the battle, before the menu comes up do this: trash$ = INKEY$. That will clear the keyboard buffer.
 
I tried the trash$ = Inkey$ but it didn't do anything.
 
>I tried the trash$ = Inkey$ but it didn't do anything.

Like,

Code:
trash$ = Inkey$
while trash$<>&quot;&quot;
  trash$ = Inkey$
wend

(As far as I remeber keyboard stores up to 16 keypresses)
 
def seg=&h40
poke &h1a,peek (28)
def seg

this will empty the keyboard buffer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top