I am trying to use EventHandler to detect KeyDown within a LocatorPane. Anytime I press a key inside the LocatorPane the proper action is not executed (doesn't matter which key I choose) but rather the the symbol of the key pressed appears in the next input line below the LocatorPane (i.e. it jumps out of the LocatorPane). I must be missing something simple because this works fine with {{"MouseClicked",2} :> (AppendTo[someList, 1]; Print[someList])} but not as shown below with {{"KeyDown", a} :> (AppendTo[someList, 1]; Print[someList])}. Btw, in case it's not obvious I am using the right mouse button for the click because the LocatorPane responds to the left button. Any suggestions on getting this to work properly with KeyDown? - GR
(* code below does not respond to "KeyDown" events but will respond properly to
"MouseClicked" *)
pts = {};
someList = {};
EventHandler[
LocatorPane[Dynamic[pts], Graphics[Circle[], ImageSize -> 500],
LocatorAutoCreate -> True,
Appearance -> {Graphics[{Red, Disk[]}, ImageSize -> 10],
Graphics[{Blue, Disk[]}, ImageSize -> 10]}],
{{"KeyDown", "a"} :> (AppendTo[someList, 1]; Print[someList])}
]