Getting a key identifier

Just starting out? Need help? Post your questions and find answers here.
CharlesT
User
User
Posts: 20
Joined: Sun Jan 07, 2018 10:09 pm

Getting a key identifier

Post by CharlesT »

Hi, all.

Is there a way to read into a variable the identifier of a key that has been pressed?

For example, the value of the constant #PB_Key_Up is 200. Is it possible to return that value when the key is pressed?

Thank you for your time.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Getting a key identifier

Post by netmaestro »

Depends, are you working with sprites and screens or on the OS gui? If so, what OS?
BERESHEIT
CharlesT
User
User
Posts: 20
Joined: Sun Jan 07, 2018 10:09 pm

Re: Getting a key identifier

Post by CharlesT »

netmaestro wrote:Depends, are you working with sprites and screens or on the OS gui? If so, what OS?
Hi, netmaestro. I'm working with sprites and screens. To explain further: I would like to store, in a variable, the key constant value of the key that is pressed by the user. One way to do this would be to use a series of If statements or Select statements, checking for every possible key constant. But I wondered if there was a simple way of finding out the key constant value of whatever key was just pressed.

Thanks.
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Getting a key identifier

Post by #NULL »

Multiple keys can be pressed at the same time, thats why there is no such functionality. You need to know what key you are looking for.
Post Reply