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!

input problem

Status
Not open for further replies.

andyjdavis

Programmer
Aug 10, 2000
23
AU
I have noticed that using the method for checking for user input used in most example code, ie IF INKEY()=whatever, only allows for one key to be pressed at a time. Although the special keys seem to be excempt from this if you use IF LEFTKEY()=1 it is still anoying that only one alphanumeric key can be pressed at once. Does anybody have a way around this? This code needs to operate within the a game and will check for player input. As such the ability to press any number of keys simultaneously would be desirable. Thanks for any assistance.
 
i think you have to creat two imputs but to be honest i dont know any keys other than the basic keys what are the number inputs?
 
Have you tried doing it with nested if statements for each key you want to check? the computer wouldnt run a key check for more than 1 key at the same time, it might be a millisecond difference but it would still do one after the other.

So if you want to check for keys A and U

If A then
If U then
Else
End If
End If

If U then
IF A then
Else
End If
End IF

Just an example, but would get a bit tedious if you want to check for a lot of keys.

---------------------------------------

Neil
 
Sorry missed an else off but you get the idea.

---------------------------------------

Neil
 
Close here is my example of key presses
As example say a = 100 and u = 200

if keystate(100) then "Your Variable"=1
if variable=1 and keystate(200)=1 then variable=2
if variable=2
place commands here
endif
if scancode()>0 and keystate(100)=0 and keystate(200)=0 then variable=0

Things like that.

Also if you want to keep track of what is pressed you could use an array, so if u where looking for someone to type 'AAU' in that order

Something like

Keypresses(4,1)
if Keypresses(2,0)=100 and keypresses(3,0)=100 and keypresses(4,0)=200 and keypresses(4,1)-keypresses(2,1)<2000 then
..... Do whatever you want.....
endif

Hope that helps

---------------------------------------

Neil
 
If your not sure about the 2000 its 2 seconds in milliseconds just something i added to make sure the person types the letters in that order with the given time.

---------------------------------------

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top