Hi Steve,
I have a message-based key decoder that runs as a background task, sampling the switches when scheduled to do so by a timer interrupt. Its features are:
It currently supports 16 switches on two ports, but expandable, if needed.
Differentiates between a switch being 'clicked' and a switch being 'held'.
The time-difference between a 'clicked' switch and a 'held' switch is selectable.
Keys can be programmed auto-repeat.
Supports an unlimited amount of key rollover.
Messages are issued when any key event occurs. The key events are:
KeyPressed: the key was pressed down
KeyClicked: the key was pressed and released quickly
KeyHeld: the key has been pressed long enough to be 'Held' (typically 1 second)
KeyRepeat: the key has been down for an additional 1/4 second (time is selectable)
KeyHoldEnd: the key was 'Held', but is now released
KeyReleased: the key was let back up
Some actions can generate more than one message. As an example, when a key is released a "KeyReleased" message will be issued, but either a "KeyClicked" or "KeyHoldEnd" will also be issued, depending on how long the key was down. This way, the receiving task can decide which messages it cares about.
I'm not sure if this is what you want to get into, but if it is I can post the code. It is written to run as a task, not as an ISR. A timer interrupt queues it up to my nano-scheduler, which then runs it.
Oops, I forgot to ask if you needed C or assembly language. My code is written in assembly language.