How to use a single button with something similar to morse code for options?

I want to be able to select different options in my loop. I could use i.e. a few digital or analogue inputs and use if, else, switch, etc.

But my idea is to do this with just one button and commands like morse code.
If I press Long, short, short A happens
If I press Long, Long, Long B happens
And some more options.

Currently I use no wait and I run a timer every 10 ms. I could change this to another ms value or use a different timer. My loop time does not have to be precise. +/- 10% is no problem.

#include <MsTimer2.h>

void setup() {
  MsTimer2::set(10, timedLoop);
  MsTimer2::start();
}

void timedLoop(){
  //work
}

I guess I could monitor for how long a button is pressed. And then look for a pattern like "long, short, short" and other options.
But before I try to do that from scratch I thought I ask the community if there is some public code for this or maybe a library.
There is no point to "invent" this again if others did it already.

Any ideas?
Thanks

Why not start with a CW trainer like this and then decide what to do with the character that was typed out.

This Thread has a neat way of dealing with different button presses.

If you make the thing too complicated it will be unusable.

...R

Thanks for the two options. That looks already very interesting and will save me a lot of work.