I'm at a bit of a loss with what to do here. I want to have certain sequences of keystrokes perform certain actions.
I basically need to store the last N keystrokes, and when a key is pressed, look for a sequence that matches the most recent keystrokes.
So say I have 2 sequences:
yes
no
and as I type, my keystroke history looks like this:
a
ab
abc
abcn
abcno
at which point it should recognize the sequence no
and perform the appropriate action.
It will also need to work with sequences such as:
year
yell
and input such as:
yeayell
Key sequences are of a finite length, so old keystrokes can be discarded, using something like a circular buffer, in this case with an optimal size of 3.
My keystrokes are represented with the Keys
enum.
What data structure(s) or algorithm(s) should I use that will let me store the last N keystrokes and find sequences at the end?