0

I have a textbox that I want to the user to write something in it. I want that the default language there would be english. so if he pressed alt-shift before he came to my page and he is now on other language - when he'll come to my textbox it would change his language to english. Is it possible with javascript? how?

4
  • 1
    Sure, you can grab keypresses and do redirects in Javascript... but wouldn't it be much more intuitive for the user to just have a little flag link in the corner of the page to change to a different language? That's what most people expect nowadays, I would think. Commented Aug 11, 2009 at 11:30
  • I've got no idea what it means for "the default language to be english". Do you want to show a different webpage in English around your textbox? And what does alt-shift mean? Commented Aug 11, 2009 at 11:35
  • 1
    I believe Alt-Shif refers to the standard hotkey of MS Windows' "language bar", which you can use to quickly switch between different keyboard layouts. No idea why you'd want to do this in webpage, though. Commented Aug 11, 2009 at 11:38
  • 1
    -1 The author needs to explain what he wants better. Commented Aug 11, 2009 at 11:46

2 Answers 2

3

I'm not sure what you mean by "pressing Alt-Shift". Are you referring to the keyboard layout switching hotkey in recent versions of MS Windows?

If yes, then the answer is "no". The layout switching is performed by the operating system and not accessible from Javascript. Which is a good thing, BTW. You would not want a webpage (or even a local application) to switch around your keyboard layout.

Incidentally, I do not understand why you would want to change the layout. If the user is comfortable with, say, a German or French layout, how does it help to change the layout?

Maybe you could elaborate on your problem. What are you trying to solve?

Sign up to request clarification or add additional context in comments.

1 Comment

the customer wanted that when the customer would start writing things n the textbox. the language that he would have will be english (if he has it in his os)
1

This is not possible, but the thing is possible is check if the char is english. It will forbid chars from Chineese, Russian etc...

4 Comments

How would you prevent "characters from Dutch"? It's clear you can reject characters from non-Latin scripts, such as Cyrillic or CJK. But there are plenty of languages written in pure ASCII.
Not to mention that many characters which can't be done with pure ASCII are often written with pure ASCII anyway (Füße = FuBe, té = te).
it would be simpler to allow what you want and disallow anything else, but it would be confusing to the user, as they would type and not understand why nothing in being written.
@Djko So you would catch Russian but not Dutch? What's the point in a solution that only works on 50% of the world's languages?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.