bug fixed for handling keyboard events