Handle special KE_EVENT case where maxlen < 3

Possible bug reported by @oni-link [here](https://github.com/neovim/neovim/pull/485/files#r11664573).

It was handled by walking through a key buffer in a circular way and saving
the index between calls with a static variable.

Also replaced some `char_u` occurrences by `uint8_t`.