Reputation: 15814
Assuming that the user's keyboard is set to a US English keyboard setting, is it possible to create an html text box with a button like "Vietnamese" that when clicked, will begin storing all user input as the Vietnamese keyboard input method?
For example, if I couple the button to the vietnamese-vni input method, and using my default US English keyboard, I typed: this is Vietnamese:
then I clicked the button, and typed tie4ng vie6t
, I want the text area to render this is Vietnamese: tiẽng viêt
I wonder if there is a way to do this in html/css/javascript?
Upvotes: 4
Views: 1777
Reputation: 11725
It's not so simple to make your own script, but there is a library that does exactly what you want:
(function() {
var txt = document.getElementById('vin'),
btn = document.getElementById('change'),
vin = false;
VNTYPING.VNID = ['vin'];
VNTYPING.SetMethod(0);
btn.addEventListener('click', function() {
vin = !vin;
btn.textContent = vin ? 'ENG' : 'VIN';
VNTYPING.SetMethod(vin ? 1 : 0);
txt.focus;
});
})();
<script src="http://www.vntyping.com/vntyping.min.js"></script>
<textarea id="vin"></textarea>
<button id="change">VIN</button>
Upvotes: 3