On KeyDown Bug

Jim Ault JimAultWins at yahoo.com
Mon Mar 27 16:28:59 EST 2006


Hmmm, I guess I am not sure why you would use 'switch' without a
switchExpression (according to the docs).  Seems to me that you are tempting
fate and the switch structure to decipher what you want.
> on keyDown theKey
>    local theModifier
>    put "" into theModifier
>    switch
>    case the optionKey is down
>      put "Opt " after theModifier
>    case the CommandKey is down


You could try
on keyUp theKey
  local theModifier
  put "" into theModifier
  put "Opt Cmd Shft Ctrl" into keyStr
  put (the optionKey is down) && (the CommandKey is down) && \
      (the shiftKey is down)&& (the controlKey is down) into mods
  repeat with x = 1 to the number of words in mods
    if (word x of mods) then put word x of keyStr & "-" after theModifier
  end repeat
  delete last char of theModifier
  put theModifier && theKey
  pass keyUp
end keyUp
--this work, sort of, but not in all cases.  Please read the following:

The keydown message is not the only one you need to consider.
Suggestion: turn on the Message Watcher (in the Development menu)
and note the messages passed with different key presses, especially the
keyUp+optionKeyDown+controlKeyDown+rawKeyDown

Hope this helps.

Jim Ault
Las Vegas

On 3/26/06 7:50 PM, "Robert Sneidar" <bobs at twft.com> wrote:

> Hi Everyone. This may be a bug, I do not know. Observe the following
> snippet in the script of the stack:
> 
> on keyDown theKey
>    local theModifier
>    put "" into theModifier
>    switch
>    case the optionKey is down
>      put "Opt " after theModifier
>    case the CommandKey is down
>      put "Cmd " after theModifier
>    case the shiftKey is down
>      put "Shft " after theModifier
>    case the controlKey is down
>      put "Ctrl " after theModifier
>    end switch
>    put char 1 to -1 of theModifier into theModifier
>    replace " " with "-" in theModifier
>    put theModifier && theKey
>    pass keyDown
> end keyDown
> 
> This SHOULD put the modifier keys and the key typed in the result of
> the message box. It works when I just type letters. BUT when I use a
> modifier that is NOT the shift key, I get NOTHING. IF I use the Shift
> key I get "Shft-Crtl " followed by the letter typed, even though the
> Control key is NOT down!
> 
> Well this cannot be right! What is really needed is a new argument in
> the keyDown and keyUp handlers for the modifier keys. I should be
> able to write the handler this way:
> 
> on keyDown theKey, theModifiers
> if "Shift" is in theModifiers then
>    -- some stuff here
> end if
> pass keyDown
> end keyDown
> 
> I guess this is a bug report AND a feature request.
> 
> Bob Sneidar
> IT Manager
> Logos Management
> Calvary Chapel CM





More information about the use-livecode mailing list