Refactor keyboard/click/touch-handling