Improved keyboard handling.