Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To see <strong>if the Return key was touched</strong> I add onKeyPress to the HTML body tag like this</p> <pre><code>&lt;body onKeyPress="return returnKeyPressed(event)"&gt; </code></pre> <p>There is a javascript function on the page that looks like this</p> <pre><code>function returnKeyPressed(event){ if(window.event.keyCode == 13) document.location = "returnkeypressed:"; return true; } </code></pre> <p>And I have this in the class that is the webView delegate</p> <pre><code>- (BOOL)webView:(UIWebView*)aWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType{ NSString *requestString = [[request URL] absoluteString]; NSArray *components = [requestString componentsSeparatedByString:@":"]; NSString *theTask = (NSString *)[components objectAtIndex:0]; if([theTask isEqualToString:@"returnkeypressed"]) [aWebView endEditing:YES]; } </code></pre> <p>This just ends all editing in the webView, dismisses the keyboard, and removes focus from any specific textarea or input.</p> <p>How to change the "label" of the Return key in a webView situation (to something like 'Done') is still a mystery to me. Ideas?</p> <p>UPDATE: I changed the javascript function to this</p> <pre><code>function returnKeyPressed(event){ if(event.srcElement.nodeName == 'INPUT' &amp;&amp; window.event.keyCode == 13) document.location = "returnkeypressed:"; return true; } </code></pre> <p>to allow the return key to function normally in textareas.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload