Fixed history search on up and down keys