I'm currently trying to figure out how to detect when keys are being pressed on a keyboard in an iOS application. The problem is that the input boxes and textfields are apart of HTML in the UIWebView. I know you can check if the keyboard has been shown or hidden, but i seem not to be able to get the key presses to register as a touch event. I know there is the way of using javascript to pick up the events.
for example
JavaScript:
$(function(){
$('input, textarea').keypress(function() {
window.location = "randomURL://fakeURL";
});
});
XCode:
NSURL *url = request.URL;
if([[url scheme] isEqualToString:@"randomURL"]) {
NSLog(@"Key Pressed");
return NO;
}
I'm just wondering if there is a way of doing it natively and not use the javascript as i would have to add the javascript to multiple files.
If anyone needs help with the javascript method of doing this. Just message me and i'll help you out. I just hope so one will be able to help with a native method of doing this.