bug fixing for the keydown JS