Easily Add Speech Input To Your Search Fields

Unfortunately, this only works in Chrome, but it’s super simple and easy to implement.  All you need to do is add an x-webkit-speech attribute to the proper input element.

With JQuery, we can target an input dynamically, and add in the attribute using the attr(); method. Since the attribute doesn’t require a value, we’ll need to pass the webkit speech attribbute, and an empty value to JQuery’s attribute method like so: attr('x-webkit-speech', '');

//add speech input to a text field via JQuery
$(document).ready(function(){ 
  $('#search').attr('x-webkit-speech', ''); 
});

Big thanks to phpied.com for the inspiration.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">