+ 3

How to make keyboard in web HTML?

I want to know how to make button when l click on it value 'a' appear in textbox?

20th Mar 2017, 1:10 PM
Kirollos Ayman
3 Answers
+ 11
I don't know what you call 'textbox' ( <textarea> element or any container like <div> element ? ), but in all cases ( obviously, replacing <textarea> by the element you want ): <textarea id="myTextbox></textarea> <input type="button" value="a" onclick="document.getElementById('myTextbox').innerHTML+=this.value;">
21st Mar 2017, 3:54 AM
visph
visph - avatar
+ 2
thanks very much for your answer
29th Mar 2017, 2:25 AM
Kirollos Ayman
- 1
For that you will need to download jQuery. Check Sololearn's jQuery course for downloading it or you could switch the programming language to jQuery. To make a function run when a key is pressed, type this: $('body').keydown(function() { //code goes here }) If you want a specific key to be pressed, type "alert(event.which)" in the area where the code goes. So if you press the key you want to be pressed, press it. It should output a number that is the key that you just pressed. If, for example, you pressed space, and you got 32, replace that code with this: if (event.which == 32) { //code that is executed when you press space }. So you want A to appear in the textbox. That is pretty easy for me. document.getElementById('(textarea id)').innerHTML = 'a' But you download jQuery, so if you want you could write this instead: $('#(textarea id name)').text('a') You dont need to thank me.
29th Mar 2017, 1:44 AM
koder
koder  - avatar