Fixed bug in key event listener