Hello Pidea,
thank you for the example. So far I could see the continuously log messages ''checkkeypressed' and 'lot - onKeyRelease'. This is caused by the method onKeyRelease being invoked in context of Timer. The call stack window reveals the situation:

The method onKeyRelease is invoked in two cases: (1) by the KeyHandler when the user releases the key and (2) by the Timer object as shown in the screenshot above.
The problem with this approach is, the method evaluates the variable Code from the KeyHandler. This variable (similar to other state variables existing the KeyHandler) is valid only while the KeyHandler triggers its associated slot method (e.g. OnPress, OnHold or OnRelease). Evaluating the variable at any other time point will result in the recent code (recent state) processed by KeyHandler.
You will need to adapt your code so that when the method onKeyRelease is executed in context of the Timer, the variable Code is not evaluated:. Following could be the adaptation. The affected modifications are highlighted:

Does the modification work as expected?
Best regards
Paul Banach