canvas keyevents; code cleanup