Improved keyboard events handling.