0

I have a javascript to type input values like name, address etc in html form in Devnagari (Hindi -India) language and in English with toggle. For that F9 button on keyboard to be pressed to toggle between Hindi And English language.

Is it possible to provide a link / button to user which will work as F9 when pressed and toggle languages... ?

currently I am using following javascript to enable hindi and english language to type in input fields in html form with F9 as toggle language key..

<script language="javascript" type="text/javascript">
    devnagari.addLanguage(DevIndic,"Hindi"); 
    devnagari.enable();
    devnagari.setToggleKey(120, true, false); 
</script>

With this script I can toggle hindi and english with pressing F9 button on keyboard. I want to keep a link/button to toggle this... when user clicks on it, language get toggled instead of pressing F9 button

  • sure you can add click event on button and switch between hindi and english – Priyesh Kumar Sep 04 '18 at 15:33
  • ok... can i have a sample code for this click event as I am very weak in javascript.. – Dr Manish Lataa-Manohar Joshi Sep 04 '18 at 15:35
  • You can detect which key got pressed by using [`KeyboardEvent.code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code) Please go through the whole documentation for examples and reference to know which key has what code. – KarelG Sep 04 '18 at 15:35
  • @KarelG I do not want to detect which key is pressed... It is 120 (F9)... I want to create a button to show above form to toggle between languages instead of manually pressing F9 button – Dr Manish Lataa-Manohar Joshi Sep 04 '18 at 15:37
  • oh, just create a button. hook a click event on that button. Then when the button is clicked, just call the function that swaps the language. – KarelG Sep 04 '18 at 15:40

0 Answers0