user265961
user265961

Reputation: 1373

Is there really no way to capture the backspace character?

Objective-C is said to accept "\b" as the special character for backspace, how can I capture this in program?

My purpose is to catch it in an if-statement to enable me screen characters for my textField:

if ([someCharacter isEqualToString:@"\b"]) { }

Upvotes: 6

Views: 1009

Answers (2)

user265961
user265961

Reputation: 1373

I decided to forget to capture the backspace character itself, I programmatically captured the state by comparing the lengths of the string before and after the character placing action of the textField:shouldChangeCharactersInRange:replacementString: method. This is the code:

if  ([[textField1.text stringByReplacingCharactersInRange:range withString:string] length] < textField1.text.length)
{
    //do nothing
}
else
{
    //more programme code;
}

Upvotes: 2

oneat
oneat

Reputation: 10994

GetAsyncKeyState();

By standard console OI you can't do that.

Upvotes: 0

Related Questions