How to detect UIKeyboard “backspace” button touch on UITextField? [duplicate]

if the UITextField is empty, the shouldChangeTextInRange delegate method is not called
You can subclass UITextField and override this method:

-(void)deleteBackward;
{
    [super deleteBackward];
    NSLog(@"BackSpace Detected");
}

since UITextField is compliant to the UITextInput protocol, this method is implemented, and you can override it to detect when backspace is pressed.
Then, you can write your own protocol/delegate method to alert your custom textfield delegate if the backspace is detected.

Leave a Comment