Thursday, 8 November 2018

Hide emoji keyboard in WKWebView

I want to control the keyboard displayed when using WKWebView.

I have the following swift code starting the webview:

let webView = WKWebView(frame: self.view.bounds, configuration: configuration)
webView.navigationDelegate = self

It will load html that looks like this:

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <div class="inputElement textFieldInput">
        <input type="text" id="textField" value="" data-clear-btn="true"/>
    </div>
</body>
</html>

I have done enough research to know that this can not be accomplished by using the option on the text box. I am fully expecting to write modify the code that opens the webview.

How can I modify the swift code to allow me to do this?

Ideally, I could define multiple keyboards and allow the html code to control them something like this: <input type='customkb1'> and <input type='customkb2'>

My immediate need is to disable the emojis button on the keyboard but I would like a generic solution as I will be able to really improve the usability of my application if I can define a keyboard specific to what the user is inputting.

Here is what we have found so far: That is trick I know and use for native part of the application: https://stackoverflow.com/a/25861718/1885345

But it doesn't work for webViews That is the way to specify keyboard from WKWebView: https://stackoverflow.com/a/28533488/1885345

But it doesn't have the option to set keyboard without emojis That is what I use to disable third-party keyboards: https://stackoverflow.com/a/34863426/1885345



from Hide emoji keyboard in WKWebView

No comments:

Post a Comment