Page 1 of 1

Recognising enter/return button

Posted: Wed Jun 08, 2016 8:01 am
by 17rag01l
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

Re: Recognising enter/return button

Posted: Wed Jun 08, 2016 8:24 am
by Thierry
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

Re: Recognising enter/return button

Posted: Wed Jun 08, 2016 11:26 am
by Newbie4
Look up returnInField in the dictionary

Code: Select all

on returnInField
   go to next
end returnInField

Re: Recognising enter/return button

Posted: Wed Jun 08, 2016 1:54 pm
by AxWald
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!