Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent keyboard from popping on textbox focus/click in iPad webapps

I am trying to create a custom keyboard on an iPad application. But each time the input get the focus, the native iPad keyboard pops up. How can I prevent this, in JavaScript.

like image 975
kevin_rd Avatar asked Sep 23 '10 11:09

kevin_rd


Video Answer


4 Answers

add attribute 'readonly' to your input and provide a different means of populating the value.

like image 183
timnyah Avatar answered Oct 20 '22 01:10

timnyah


I don't think you can prevent the keyboard from appearing on input fields. However you could create an html element that looks just like an input field with CSS and handle the onClick event to show your custom keyboard.

<style>
    .textField{
        width: 120px;
        height: 17px;
        border-style:inset;
        border-width: 2px;
        border-color: gray;
        float: left;
    }
</style>
<script>
    function showKeyboard(){
        alert("show the my cool keyboard");
    }
</script>

Name: <div onClick="showKeyboard()" class="textField"></div>

You should checkout Sencha Touch for developing Web Apps for iOS devices.

like image 34
alanboy Avatar answered Oct 20 '22 01:10

alanboy


The best thing to do is to stop the event on the onclick event.
html :

<textarea onclick='myOnClickEvent'></textarea>

Javascript :

function myOnClickEvent(e){
e.stopPropagation();
}

Dojo :

function myOnClickEvent(e){
dojo.stopEvent(e);
}

Sencha :

function myOnClickEvent(e){
e.stopEvent();
}

I hope this help.

like image 34
quentinous Avatar answered Oct 20 '22 01:10

quentinous


position an absolute div with a z-index:1 on top of the text input field, and attach an onclick handler to the div that launches the keypad.

Next step would be to attach the keypad numbers to affect the value of the text field.

like image 30
Ben Althauser Avatar answered Oct 20 '22 00:10

Ben Althauser