Status of keys on keyboard

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Status of keys on keyboard

Post by Garrett » Sat Jul 21, 2007 11:46 am

Greetings,

There's some great functions and messages for working with the keyboard and obtaining when keys are pressed, but I'm in need of something a little more. Determining the if the capslock key is up or down is there, but can't find anything that will help me with scrolllock, numlock and insert keys.

Does anyone know if there's a way in Rev to determine the status of these keys?

The rawkeydown returns the numerical id's for these, but still no way to determine if these keys are active or not like the capslock function.

Thanks in advance,
-Garrett

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Sat Jul 21, 2007 12:28 pm

Hi Garret,

check the docs for "rawkeydown/-up".

To get the the correct "rawkey" number of these keys, create a new stack with one field and put this into the cardscript:

Code: Select all

on rawkeydown tKey
 put tKey & CR after fld 1
 ## or "...into fld 1"
end rawkeydown
This way cou can press any key, see its "rawkey" number and use this for your scripting.

Hope that helps.


Best from germany

Klaus

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Sat Jul 21, 2007 12:29 pm

Ooops, sorry, totally overlooked your last sentence :-/

Sorry, no other ideas...

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Jul 21, 2007 1:17 pm

Hi Garrett,

Check the keysDown function in the docs.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Sat Jul 21, 2007 1:19 pm

keysdown()

Exactly, took about 2 more hours before I also had this idea, but it's hard to beat this smart dutchman anyway ;-)

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Sat Jul 21, 2007 10:08 pm

keysdown does not give me the status of the key though, merely if the key is being pressed or with keysup, if it's been released. It doesn't allow us to determine if say numlock, scrolllock or insert is active or not though. :-(

I appreciate you guys at least looking into this for me. Thanks,
-Garrett

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Sun Jul 22, 2007 1:40 am

Yeah well if there really is no way of knowing the status of those toggle-style keys, file it as a bug.

I guess only the capslock is supported because all of the other ones have long gone on the macintosh keyboards or never existed. Thus, trying to implement them in your program will render it un-multiplatform. If you avoid using them altogether, it's better. You can surly find a better GUI way of achieving what you want.

Cheers.

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Post by Garrett » Sun Jul 22, 2007 5:31 am

Alrighty then. Many thanks to all of you for replying and trying to help.

-Garrett

Post Reply

Return to “Talking LiveCode”