If some key is down

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

If some key is down

Post by croivo » Thu Apr 14, 2016 3:49 pm

Hello...
How to check if a key is down?
I know for this syntax:

Code: Select all

if the altKey is down then doSomething
But can't manage to change it to work with other keys, like regular letters, tab etc.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: If some key is down

Post by dunbarx » Thu Apr 14, 2016 4:12 pm

Is "the keysDown" function what you are looking for?

Craig Newman

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: If some key is down

Post by atout66 » Thu Apr 14, 2016 6:00 pm

If you want your application to response when the user press a function key, place this script (the beginning to give you an idea) in your main stack.

Code: Select all

on functionKey theKey
     lock Screen
     switch theKey
          case 1  -- HELP
               if the controlKey is down then -- load the main help file                    
                    launch url ("file:/"&gLePathFolder&"/Aide.pdf") 
               else -- do regular F1 (inline help)
                    .......                    
               end if
               break
          case 2 -- PREFERENCES et STATISTIQUES
               if the controlKey is down then -- STATISTIQUES
                    .....
               else -- do regular-> PREFERENCES
Cheers, Jean-Paul.
Discovering LiveCode Community 6.5.2.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10078
Joined: Fri Feb 19, 2010 10:17 am

Re: If some key is down

Post by richmond62 » Thu Apr 14, 2016 6:20 pm

Check out keyDown, keyUp, rawKeyDown and rawKeyUp;

with these you can "see" whenever ANY key is being used.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: If some key is down

Post by jmburnod » Thu Apr 14, 2016 8:20 pm

And don't forget "the keysDown" as Craig said.
Best regards
Jean-Marc
https://alternatic.ch

croivo
Posts: 111
Joined: Wed Feb 26, 2014 11:02 pm

Re: If some key is down

Post by croivo » Thu Apr 14, 2016 11:28 pm

"the keysDown" is exactly what I was looking for. Thank you all :D

Post Reply