I am trying to create a button that can pop up the speech input panel (in HTML5), and I tried to use <label>
for that:
<label>
<input type="text" x-webkit-speech />
<button>Speak</button>
</label>
http://jsfiddle.net/DerekL/XzD2U/
But it only focus on the <input>
D: And that is not I wanted to do.
Any suggestion? (it does not have to support IE nor Firefox, just Google Chrome)
This is what I want it to be: http://jsfiddle.net/DerekL/RWCJR/
but I want to use a real button instead of this fake <input>
button.
You are pretty limited in what you can accomplish. What you are after isn't possible. The only way to trigger the speech is to click on that microphone icon in the textbox. If you are willing to use javascript then I think you might be able to cram something in. This is how I would do it.
You can see in this example how I hacked it together. There are two buttons, one with the microphone overlayed completely transparent, and one with it partially transparent and a red border so that you can see the effect.
CSS
input.speechbutton {
position: absolute;
top: 0;
left: 0;
opacity: 0;
height: 20px;
width: 20px;
margin-left: 30px;
-webkit-transform: scale(3.0, 1.0);
}
HTML
<div style="position: relative;">
<button>Speech</button>
<input class="speechbutton" type="text" value="" x-webkit-speech />
</div>