Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / inkey$() problem

Author
Message
Triple Ha
21
Years of Service
User Offline
Joined: 18th Apr 2004
Location: California, but I wish I was in Japan
Posted: 22nd Aug 2004 13:51
the inkey$() command seems to not work for me. I get the "Syntax Error" error, when my code is like this:

I've also tried

Any help would be greatly appreciated.

--------------------click below--------- Skyblaze!
Edizzle
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 22nd Aug 2004 14:55
i'm pretty sure its inkey$()="8"
or you can just do scancode

http://edizzle.100free.com
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 22nd Aug 2004 17:12
If I remember correctly inkey$() deals with characters/strings.

IE:
if lower$(inkey$())="w" then gosub MovePlayerForward

Scancode's a more effective way of getting direct input from the keyboard. It uses ascii values. Google for "ASCII table".

Crazy Donut Productions, Current Project: Project Starbuks
Sony stole our name!
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 23rd Aug 2004 00:22 Edited at: 23rd Aug 2004 00:29
yeah, inkey$() returns the acsii character from the keyboard, such that if you want to detect a particular ky it must be in the form of;
if "a" = inkey$() --- for lower case A
if "A" = inkey$() --- for upper case A
if asc(inkey$()) = 65 -- for upper case A
if asc(inkey$()) = 97 -- for lowercase A
if asc(upper(inkey$())) = 65 -- for both A's
if asc(lower(inkey$())) = 97 --- also for both A's

or use the scancode() operation which returns the keyboard code for the keys themselves;
if scancode() = 30 -- for both A's

This thread contains the graphic of the scancodes;
http://forum.thegamecreators.com/?m=forum_view&t=33640&b=7

Good luck,
S.

Any truly great code should be indisguishable from magic.
Psaiko
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location: Everywhere
Posted: 23rd Aug 2004 01:13
Why don“t you use keystate?
If keystate(idontknowthenumber) = 1 the load "pick.bmp"
I think this will work.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 23rd Aug 2004 01:32 Edited at: 23rd Aug 2004 01:33
Keystate() requires the same information as scancode(), only uses it in a different way;

if keystate(30) = 1 then print "A has been pressed"

If I'm going to look up the scancodes anyway, I tend forget about the keystate() operation and just do a scancode()=30 instead.

S.

Any truly great code should be indisguishable from magic.
Triple Ha
21
Years of Service
User Offline
Joined: 18th Apr 2004
Location: California, but I wish I was in Japan
Posted: 23rd Aug 2004 04:11
Now the syntax is right, but now when I press the desired key all it does is prints its value on the CLI.

--------------------click below--------- Skyblaze!
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 23rd Aug 2004 23:32
Well now you're going to have show us the code you're using... the syntax of the command was easy, how you're trying to use it is another matter.

Any truly great code should be indisguishable from magic.

Login to post a reply

Server time is: 2025-05-25 10:53:39
Your offset time is: 2025-05-25 10:53:39