Improve the button handling code so that a pressed and held button will
now generate additional press events after a short delay.
An acceleration curve is also applied so that events are generated with
increasing frequency the longer the button is held down.
Closes#323.