Recognising enter/return button

Creating Games? Developing something for fun?

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
17rag01l
Posts: 2
Joined: Sun Jun 05, 2016 11:22 am

Recognising enter/return button

Post by 17rag01l » Wed Jun 08, 2016 8:01 am

Hey, what code would i have to use in order for livecode to recognize that when someone presses the enter/return button in order to make my game change cards

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Recognising enter/return button

Post by Thierry » Wed Jun 08, 2016 8:24 am

17rag01l wrote:Hey, what code would i have to use in order for livecode to recognize that when someone presses the enter/return button in order to make my game change cards
Hi,

You could try this:

create a field and type this line of code:

Code: Select all

on rawkeyup k
   put k
end rawkeyup
This will give you the values you are looking for.

HTH,

Thierry
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 272
Joined: Sun Apr 15, 2012 1:17 am
Location: USA
Contact:

Re: Recognising enter/return button

Post by Newbie4 » Wed Jun 08, 2016 11:26 am

Look up returnInField in the dictionary

Code: Select all

on returnInField
   go to next
end returnInField
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

AxWald
Posts: 319
Joined: Thu Mar 06, 2014 2:57 pm

Re: Recognising enter/return button

Post by AxWald » Wed Jun 08, 2016 1:54 pm

Hi,

following Thierrys reply about rawKeys:

Code: Select all

65307,SEL,Escape
65293,RET,Return
65421,ENT,Enter
65362,AUP,Arrow Up
65364,ADN,Arrow Down
65361,ALF,Arrow Left
65363,ART,Arrow Right
Explanation:
"RawKeyValue", "Shortcut", "KeyName"

These are the ones I'm using when working with keyboard navigation. This is in a custom stack prop, and I use them in a rawKeyDown handler to determine if to fire a command (using the shortcut values).

Code: Select all

on rawkeydown tC  --  check for custom commands:
   get item 2 of line lineoffset(tC & ",", the RawKeyVals of this stack) of the RawKeyVals of this stack
   if it is empty then  -- not in list, nothing to do
      pass rawkeydown
   else
      -- here: Call command for the key-shortcut (or error handler)
      exit rawkeydown
   end if
end rawkeydown
You're trying to distinguish between RETURN & ENTER, right?

Have fun!
Livecode programming until the cat hits the fan ...

Post Reply

Return to “Creating Games”