curTime = AbsoluteTime[]; curKey; keyPressed = 0; EventHandler["a", {"KeyDown" :> ( If[keyPressed < 3, If[AbsoluteTime[] > .5 + curTime, Print[CurrentValue["EventKey"]]; keyPressed++; ], If[AbsoluteTime[] > .1 + curTime, Print[CurrentValue["EventKey"]]; keyPressed++; ] ] If[AbsoluteTime[] > 1 + curTime, curTime = AbsoluteTime[]; curKey = CurrentValue["EventKey"]; keyPressed = 0; ] )} ] \!\( TagBox["\<\"a\"\>", EventHandlerTag[{"KeyDown" :> If[$CellContext`keyPressed < 3, If[AbsoluteTime[] > 0.5 + $CellContext`curTime, Print[ CurrentValue["EventKey"]]; Increment[$CellContext`keyPressed]; Null], If[AbsoluteTime[] > 0.1 + $CellContext`curTime, Print[ CurrentValue["EventKey"]]; Increment[$CellContext`keyPressed]; Null]] If[AbsoluteTime[] > 1 + $CellContext`curTime, \ $CellContext`curTime = AbsoluteTime[]; $CellContext`\ curKey = CurrentValue["EventKey"]; $CellContext`keyPressed = 0; Null], PassEventsDown -> Automatic, PassEventsUp -> True}]]\) If[curKey == CurrentValue["key"] , If[keyPressed < 5, If[AbsoluteTime[] > .5 + curTime, Print[CurrentValue["EventKey"]]; keyPressed++; ], If[AbsoluteTime[] > .1 + curTime, Print[CurrentValue["EventKey"]]; keyPressed++; ] ] If[AbsoluteTime[] > 1 + curTime, curTime = AbsoluteTime[]; curKey = CurrentValue["EventKey"]; keyPressed = 0; ] ] i ; n = 0; run = True; EventHandler["", {"KeyDown" :> ( If[run, Print["set initial time"]; i = AbsoluteTime[]; run = False;, n++ ]; If[AbsoluteTime[] > 2 + i, Print[n]; ] )} ]