Key commands not recognised

If you find an issue in LiveCode but are having difficulty pinning down a reliable recipe or want to sanity-check your findings with others, this is the place.

Please have one thread per issue, and try to summarize the issue concisely in the thread title so others can find related issues here.

Moderator: Klaus

Post Reply
odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Key commands not recognised

Post by odysseus » Tue Aug 25, 2020 2:24 pm

I am using Livecode on an iMac. the 'commandKeyDown' and 'escapeKey' commands don't work, they throw up an error when put into a script. The escapeKey doesn't work with 'keyDown' either. Any ideas?

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

Re: Key commands not recognised

Post by richmond62 » Tue Aug 25, 2020 2:38 pm

Indeed:

Mac Mini
LC 9.6.1
macOS 11.0 Beta 5

Code: Select all

on keyDown KD
   if the commandKey is down then
      put "cmdkey Down" into fld "fff"
   end if
end keyDown

on keyUp KP
   put empty into fld "fff"
end keyUp
does nothing at all.

Wonder about a bug report?

However
:

this worked:

Code: Select all

on escapeKey
   put "Yabba-dabba-doo" into fld "fff"
end escapeKey

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Key commands not recognised

Post by FourthWorld » Tue Aug 25, 2020 4:43 pm

odysseus wrote:
Tue Aug 25, 2020 2:24 pm
the 'commandKeyDown' and 'escapeKey' commands don't work, they throw up an error when put into a script.
Error messages provide guidance. What does the message you encounter say?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Key commands not recognised

Post by odysseus » Wed Aug 26, 2020 9:40 pm

CommandKeyDown is supposed to check if another key is pressed with the command key, according to the livecode dictionary, but isn’t recognised in a script, prompting a red cross. I even copied the script in the dictionary to no avail.
Similarly the escapeKey also produces a red cross.

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

Re: Key commands not recognised

Post by richmond62 » Thu Aug 27, 2020 9:16 am

Well; here's a thought . . .

If I set up a stack with a field and this in the cardScript:

Code: Select all

on keyDown KD
   if the commandKey is down then 
      put "Yup" into fld "Um"
   else
      put empty into fld "Um"
      end if
end keyDown
and I press Command + 'f', the "Find" thingy of LiveCode comes up,
and so on and so forth with ALL the key commands in the LiveCode IDE.

This obviously means that when the commandKey is pressed all things are trapped by the IDE before they get to the cardScript.

I have reported exactly this here: https://quality.livecode.com/show_bug.cgi?id=22881

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1232
Joined: Thu Apr 11, 2013 11:27 am

Re: Key commands not recognised

Post by LCMark » Thu Aug 27, 2020 9:23 am

@odysseus: commandKeyDown and escapeKey are events to be handled, not commands to be executed. i.e.

Code: Select all

on keyDown pKey
  answer "The user pressed" && pKey
end keyDown

on commandKeyDown pKey
  answer "The user pressed Cmd+" & pKey
end commandKeyDown

on escapeKey
  answer "The user pressed escape"
end escapeKey
Note: You won't get both keyDown and commandKeyDown - you get the former if Cmd is not held down, and the latter if it is.
Last edited by LCMark on Thu Aug 27, 2020 9:42 am, edited 1 time in total.

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

Re: Key commands not recognised

Post by richmond62 » Thu Aug 27, 2020 9:35 am

I almost love you. 8)

Code: Select all

on commandKeyDown CKD
   put "Yup" into fld "Um"
end commandKeyDown

odysseus
Posts: 42
Joined: Tue Aug 25, 2020 2:15 pm

Re: Key commands not recognised

Post by odysseus » Thu Aug 27, 2020 6:45 pm

I understand they are events, my title was misleading, but the point is that on my system ‘on commandKeyDown’ is not recognised at all and causes the red cross to be shown, so the script will obviously not compile.

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

Re: Key commands not recognised

Post by richmond62 » Thu Aug 27, 2020 7:41 pm

Dunno: this works with me:

[macOS 11.0 beta 5, LiveCode 9.6.1]

Code: Select all

on commandKeyDown KD
      put KD into fld "ff"
end commandKeyDown
-
Screenshot 2020-08-27 at 21.39.16.png
Screenshot 2020-08-27 at 21.39.16.png (20.97 KiB) Viewed 3073 times
-
Mind you; I have a "funny feeling" about pKey. 8)
Attachments
slightly foolish.livecode.zip
Here's the stack.
(898 Bytes) Downloaded 120 times

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

Re: Key commands not recognised

Post by dunbarx » Tue Sep 01, 2020 2:30 pm

...the point is that on my system ‘on commandKeyDown’ is not recognised at all and causes the red cross to be shown, so the script will obviously not compile.
Do you mean that this will not stand happily in the SE?

Code: Select all

on commandkeyDown
end commandKeyDown
Craig

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

Re: Key commands not recognised

Post by richmond62 » Tue Sep 01, 2020 7:24 pm

Ihope you haven't "been bonkers" like me
and messed around with your modifier keys settings:
-
Screenshot 2020-09-01 at 21.23.16.png

Post Reply