fix bug which caused arrow keys not to work properly