calculate mouse position
key events