# EventHandler and Dynamic

I just found a behaviour of an EventHandler that I cannot explain. Here is a highly simplified version. I will present two simple EventHandlers. The first one shows the behaviour that I would have expected from the second one as well.

eventlist=Table[Invisible["10 pressed"], {10}];
eventnr=1;
aux[arg_String]:= (
eventlist=Take[Append[eventlist, ToString[eventnr]<>arg],-10];
eventnr=eventnr+1
);

Row[{
EventHandler[Framed[Style[x^2, 30]],{{"KeyDown","1"}:>aux[" pressed"]}],
Spacer[10],
Framed[Dynamic[Column[eventlist]]]
}]


When we click in the left box and then press the key 1 a number of times, we see in the right box how often we pressed the key. This works fine.

Now I place the Dynamic expression in the EventHandler:

eventlist = Table[Invisible["10 pressed"], {10}];
eventnr = 1;
aux[arg_String] := (
eventlist = Take[Append[eventlist, ToString[eventnr] <> arg], -10];
eventnr = eventnr + 1
);

EventHandler[
Framed[Dynamic[Column[eventlist]]]
, {{"KeyDown", "1"} :> aux[" pressed"]}
]


When I click in the box and press 1, it is recognized. But further pressing 1 has no effect, so it seems that the selection must have moved outside the box. When we click again in the box and press 1, it works, but only once. Can someone explain what is happening here?

It is not an EventHandler thing.... You can think of Dynamic as a placeholder. Whenever this Dynamic triggers, the current visual tree from that point down is replaced with a completely new one. When that happens, it is not always possible, desirable, etc... to restore the selection back to an equivalent position.
To prevent the selection from diving into the underlying Grid, you can use something like Dynamic@Style[Column[eventlist], Selectable -> False] instead.