How to Use Google Input Tools in Website

javascript, jquery

Solution

If you want to add google input tools you can use below code to add it

    
      // Load the Google Transliteration API
      google.load("elements", "1", {
        packages: "transliteration"
      });
    
      function onLoad() {
        var options = {
          sourceLanguage: 'en',
          destinationLanguage: ['gu', 'ml', 'hi', 'kn', 'ta', 'te'],
          shortcutKey: 'ctrl+m',
          transliterationEnabled: true
        }
    
        // Create an instance on TransliterationControl with the required options.
        var control = new google.elements.transliteration.TransliterationControl(options);
    
        // Enable transliteration in the textfields with the given ids.
        var ids = ["language"];
        control.makeTransliteratable(ids);
    
        // Show the transliteration control which can be used to toggle between English and Hindi and also choose other destination language.
        control.showControl('translControl');
      }
    
      google.setOnLoadCallback(onLoad);
    

 
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
  
<textarea name="hi"  rows="6"  id="language" cols="6" style="width:600px;height:70px" ></textarea>

<div id='translControl'></div>

Problem

Can you please let me know if it is possible to use Google Input Tools in a website using client side scripting like jquery or pure javascript? Is there any API available for Google Input Tools? I already google this but couldn't find any thing? Thanks

Original source