Reputation: 1260
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?
Upvotes: 2
Views: 1062
Reputation: 11255
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"
Upvotes: 2