key combos


Quick question:
I’m trying to write a function that will do A when F4 is pressed, but do something else entirely (B) if f3 then f4 is pressed, and maybe do ‘C’ is F3 then F7 is pressed… They don’t need to be held down at the same time, just one after the next.

Being able to set some type of variable would be great - but i can’t seem to find a way to do so. I’ve been trying to write a complex function to do this, using State, but I think that I am doing it all wrong (which wouldn’t be surprising really)

Any throughts?


You would want to read this entry in the FAQ:

You need to temporary change the meaning keays when F3 is presed, and then cahnge it back if no other key was pressed within a short time. (Or have a cancel key that you always can cancel any key combo with)

Not quite, as that’s not answering the question. All you really need to do is to set an Env var to keep a count of the number of times a key has been pressed, and change the action it’s bound to as apropos [1].

– Thomas Adam

[1] I don’t generally like to advocate the use of polluting the environement unnecessarily, but in this instance, it suffices.