Slightly safer keyboard input code