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.

Dark GDK / Detecting if keys are pressed down?

Author
Message
CokeBoi
15
Years of Service
User Offline
Joined: 19th Jun 2009
Location:
Posted: 15th Aug 2009 10:13
Hi, I am a beginner at dark GDK and I was wondering how i could detect keys being pressed down such as W,A,S,D. TY in advanced!

LOL
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 15th Aug 2009 15:12
dbKeyState(code);


Your signature has been erased by a mod
CokeBoi
15
Years of Service
User Offline
Joined: 19th Jun 2009
Location:
Posted: 15th Aug 2009 22:59
How do I find out what to put in the 'code' parameter?

LOL
Wizz
15
Years of Service
User Offline
Joined: 27th Apr 2009
Location:
Posted: 16th Aug 2009 01:56
Each key has it's own number. For example 'w' is 17. So if you want to use 'w' you write dbKeyState(17). I added an image of all the keys' codes.

I just love the smell of code in the morning...

Attachments

Login to view attachments
CokeBoi
15
Years of Service
User Offline
Joined: 19th Jun 2009
Location:
Posted: 16th Aug 2009 02:20
So I'm guessing E is 18? does that mean 26 is A 27 is S and 28 is D?


P.S. I dont see the picture

LOL
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 16th Aug 2009 05:12
That's because you have to click the 'view' button at the bottom right of his post.

To answer your question; no. 26 is not A, 27 is not S, and 28 is not D.


Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 16th Aug 2009 06:13
They are the keyboard scancodes.

You can find out which one is which by using the command :

int dbScanCode();

It's return value, if higher than 0, will be the scancode of the key that is pressed, so you could easily write a little program to display the value that dbScanCode is returning to the screen and write down what that number is for each key you press, then you could just make a list so you know which code is for which key... would also be good practice to get to know GDK.

PS . If you have a look around there are various lists of scancode defines in header files, I think dinput.h has a set of scancode defines that you can use ... ill post a half complete set here that will get you started :



If it ain't broke.... DONT FIX IT !!!
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 16th Aug 2009 11:46
You can find a predefined list of keyboard scan codes in the "dinput.h" file, which is in your DirectX SDK installation. (Default location is Program Files/Microsoft DirectX SDK (August 2007)/Include directory.) Search for DIK_ and you will find the list of scan code constants. You can either include this header in your program or just copy the list of codes you want to use.

Login to post a reply

Server time is: 2024-10-01 10:31:14
Your offset time is: 2024-10-01 10:31:14