2

I'm developing a Web App and trying to find a way to show the soft keyboard in Android browser when user tap a canvas. I found a very simple way to do that with iOS, but with Android seems not possible.

<canvas id="myCanvas" style="width:100px;height:50px;background-color:gray" tabindex="0" contenteditable="true"></div>
...
$(document).ready(function() {
    $('#myCanvas').click(function(e){ $(this).focus(); });
})

Above code works in iOS, but not in Android. Also I don't really like the contenteditable=true, because it shows a blinking cursor in iOS and tested with div in Android it lets you write directly into the div.

I googled to find a solution, but none of the solutions works.

Any suggestions?

1 Answer 1

2

Try with this.

$(document).ready(function() {
    $('#myCanvas').click(function(e){
        $(this).focus();
    });
    $('#button').click(function(e) {
        $('#myCanvas').trigger('click');
    });
});

Add this line in your Menifest file in Activity tag.

android:windowSoftInputMode="stateVisible"
Sign up to request clarification or add additional context in comments.

4 Comments

I tried adding a button as you suggested, but no way. The canvas takes the focus, because I see a yellow border around it, but the soft keyboard doesn't jump out.
Maybe I was not clear in the main description, but I'm not developing an Android App, but a Web App, so I have no way to set a Manifest.
you mean web app using phonegap ?
Unfortunately no, just a "simple" HTML page with a bunch of JS libs, so no PhoneGap, Appcelerator, Xamarin of something similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.