Improved mouse and keyboard implementation

Now using the event iterators. furthermore fetching input was separated
from processing the input