I seem to be able to use EventHandler to handle mouse events, but not keyboard events. Here is a working example with MouseClicked -- it makes the picture smaller every time the right mouse button is clicked. For the example, the t variable is a dummy and doesn't do anything.
s = 1; Manipulate[EventHandler[{s, ImageResize[img, Scaled[s]]},
{{"MouseClicked", 2} :> (s = 0.9 s)}], {t, 1/2, 2}]
But if I replace the MouseClicked with a
s = 1; Manipulate[EventHandler[{s, ImageResize[img, Scaled[s]]},
{{"KeyDown", "."} :> (s = 0.9 s)}], {t, 1/2, 2}]
Then it doesn't change the size. It appears that the focus of the keyboard/typing is not passed to the correct level. This is basically the same as this question which was asked several years ago and doesn't appear to have been successfully answered (at least none of the proposed answers works in my case).
"x"
, not"."
, if you click the image before pressing the key (hardly a sarisfactory solution):CellPrint[ ExpressionCell[ Manipulate[ EventHandler[{s, ImageResize[img, Scaled[s]]}, {{"KeyDown", "x"} :> (s = 0.9 s)}], {t, 1/2, 2}], "Output", CellEventActions -> {PassEventsDown -> True}]]
. Maybe it will help.... $\endgroup$