Refactored to account for keyup is sometimes a deletion