Set default language for HTML input`s

后端 未结 2 1510
渐次进展
渐次进展 2020-12-06 11:16

How to set default keyboard layout for input boxes, for example when the page gets loaded, we can type in an input text with another keyboard language else than English?

相关标签:
2条回答
  • 2020-12-06 11:54

    I'd think about the lang attribute. But this is meta-information, I'm really not sure the browser will do anything with it. Never tried it myself.

    <input lang="is" ...>
    
    0 讨论(0)
  • 2020-12-06 12:04

    I think that it's possible to catch a keyCode of the button, that was pressed, with javascript and then replace the symbol to the appropriate symbol from array.
    This code helps to understand how to catch a keyCode (it does not depend on keyboard language)

    <form>
    Char: <input type="text" id="char" size="15" /> Keycode: <input type="text" id="keycode" size="15" />
    </form>
    
    <script type="text/javascript">
    
    var charfield=document.getElementById("char")
    charfield.onkeydown=function(e){
    var e=window.event || e
    document.getElementById("keycode").value=e.keyCode
    }
    
    </script> 
    
    0 讨论(0)
提交回复
热议问题