title: Need to know when user has clicked 'return' on keypad in iOS
body: <p>I am working on an application in iOS that displays a random string to the user, and asks the user to enter that same string through the keypad.  What I would like to do is compare the string the user has entered, ONLY after they have pressed the 'return' key.  Is this possible?</p>
  
  <p>Here is my relevant method that I am doing this in:</p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  
  
      if (textField.tag == 1)
      {
  
              userString = @"";
              userString = keypadText.text;
  
              [keypadText resignFirstResponder];
  
             //here 'rand' is the random string that was presented earlier to the user, and userString is the text that the user has entered.
              if ([userString isEqualToString:rand]) {
  
                  //do something
  
              }
  
              else {
  
                  //do something else
  
              }
  
              [self.navigationController popViewControllerAnimated:YES];
  
  
      }
  
      return YES;
  
  }
  </code></pre>
  
  <p>As I said, I ONLY want to do the comparison after the user has pressed the 'return' key, and up until then, allow the user as much opportunity to enter the given text, and make whatever corrections necessary. </p>
  
  <p>Can someone show me how to do this?</p>