fixing a bug that prevents mouse and keyboard event output

lastVTime update was too early.
fixing bug: mouse output has a field "button", not "key"
major refrac to simplify the main loop; untested

may be dirty