I have looked around for ways to detect when the delete key is pressed. I came across Apple’s key handling documentation and also some people trying this with work arounds. I am not sure which method to pursue. What I want to do is very simple:
-(void)deleteKeyWasPressed {
if (myTextField.text.length == 0) {
[previousTextField becomeFirstResponder];
}
}
But as far as I know this method does not exist.
What would be the best way of doing this?
iOS has no direct support for detecting the delete key (or any key other than Return). The best you can do is implement the
textField:shouldChangeCharactersInRange:replacementString:delegate method. When the user taps the Delete key, the replacement string will be the empty string.