Recognising enter/return button

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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: 875
Joined: Wed Nov 22, 2006 3:42 pm

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
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 327
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: 578
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!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply

Return to “Games”