Avoiding TypeError message when the input is empty and some key (like Backspace) is pressed