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.

Author
Message
BOC4J
22
Years of Service
User Offline
Joined: 31st Oct 2002
Location: United Kingdom
Posted: 18th Nov 2002 14:30
is there any commands to detect whether a key say "K" for example are being pressed?
i know about the alt/Ctr/shift/space/esc, but i cant find any others
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 18th Nov 2002 15:41
Try 'if inkey$()="k" then print "K was pressed"'

Hope this helps

Whatever I did I didn't do it!
Mirthin
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Land of the Rising Haggis
Posted: 18th Nov 2002 19:15
You can also use scancodes, codes that define what key is pressed, which works for every key on the board. This even includes Print Screen, all 3 locks and Pause.

This has "Fiasco" written all over it.
xtom
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Ireland
Posted: 18th Nov 2002 20:47
If your going for in game responsive controls go with scancode() or keystate(). I think keystate() is better again for controls but I'm not sure.
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 19th Nov 2002 00:41
Keystate() is used if you want to check for a specific key, and so is useful for game controls. Scancode() is used if you want to see which key the user presses, and so is useful for a text editor or something.
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 19th Nov 2002 01:59
to find the scancodes just run this and note down what keys do what or make it into a little function to see it in game as a debug screen




AnalSauceMonkey
22
Years of Service
User Offline
Joined: 24th Oct 2002
Location: I can't find myself
Posted: 19th Nov 2002 02:33
scancode() is used to check one key at a time.
keystate() can be used for multiple keypresses.
AnalSauceMonkey
22
Years of Service
User Offline
Joined: 24th Oct 2002
Location: I can't find myself
Posted: 19th Nov 2002 02:38
use indi's code snippet to find the scancode() and if you want to check more than one key at a time then put the scancode() between the ()s in keystate()
TGWDNGHN
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location:
Posted: 19th Nov 2002 22:52
and inkey() can be used to find the "text" version of whats being pressed...if k is pressed then k will appear BUT if SHIFT AND THEN k is pressed the K (not k) will appear

If life gives you a lemon, shove it up a water gun and squirt it into someone's eyes!
BOC4J
22
Years of Service
User Offline
Joined: 31st Oct 2002
Location: United Kingdom
Posted: 20th Nov 2002 12:24
so, for say the F1 key would i just say:

IF keystate(f1)=1 THEN ......

or is there a number for each key on the keyboard

TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 20th Nov 2002 14:20
There is a number for each key.
The "(" and ")" in keystate should be the scancode.
To check for the Return key use this:


To find other scancodes use indi's snippet. If you press return it should print 10. (Not testet)

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.
BOC4J
22
Years of Service
User Offline
Joined: 31st Oct 2002
Location: United Kingdom
Posted: 20th Nov 2002 15:53
thnx

TheCyborg
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Denmark
Posted: 22nd Nov 2002 11:30
Youre Welcome

TheCyborg Development.
http://TheCyborg.Amok.dk
The Ultimate Source To DarkBASIC Programming.

Login to post a reply

Server time is: 2024-11-23 17:58:16
Your offset time is: 2024-11-23 17:58:16