Click here to Skip to main content
15,903,743 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi friends,

I am working on a C# application(Custom Word Processor in local language). The local language uses most of the letters of the English alphabet except the letters "q" and "x" which should be replaced with "ɛ" and "ɔ".

After wandering through Google, a hit gave me an idea of activating Hebrew keyboard layout and this may help me get the desired symbols anytime the "q" and "x" are pressed(as I already have font files that support the characters "ɛ" and "ɔ").

The problem is how to use this Hebrew keyboard layout in my C# application.

Any help is greatly appreciated.
Posted
Updated 28-Apr-11 1:31am
v2
Comments
Slacker007 28-Apr-11 7:32am    
In the future don't say anything about this problem being urgent. It can annoy people.

As I understand, you only needs a Hebrew keyboard layout. It's absolutely the best to have it system-wide. What's wrong with one of the standard layouts bundled with Windows?

Well, I know what can be wrong. I use non-standard keyboard layout from third-party; free but no Open Source, unfortunately. Actually, this keyboard — "phonetic" — layout is extremely valuable (always provided by most distro of Linux) and maybe highly used (if not more then the standard one, I don't know), but Microsoft is so careless about it so it was never included in any version, even though there are many people who cannot leave without it.

So, you may want to try to ask an advice from the advice from the author of this product, which is practically the only one good for my culture. See http://winrus.com/kbd_e.htm[^]. I don't think he does Hebrew but he may know how to approach the problem of system-wide keyboard layout.

(Again, are you sure everyone bundled with Windows is not good?)

If you want to stay with the application-specific keyboard layout, this is more easy.
You can follow the idea shown by Nagy, but of course it should be done more seriously. Use System.Collections.Generic.Dictionary<char, char> for character translation dictionary; always persist it on the disk, provide a feature to replace it during run-time.

You also need to present an image of the altered keyboard on screen, otherwise your user will be lost.
The best thing to do it is creating your own Virtual Keyboard.

Here you can find the key recipe for doing it:
Application focus getting and losing[^],
Programming on BACKSPACE button[^].

See also this CodeProject article: A software Virtual Keyboard for your WPF apps[^].

—SA
 
Share this answer
 
v2
Comments
Nish Nishant 28-Apr-11 15:54pm    
My vote of 5!
Sergey Alexandrovich Kryukov 28-Apr-11 16:26pm    
Thank you, Nishant.
--SA
If you're looking at hebrew entry, then the user will probably be using a hebrew keyboard to get the correct codes.

If you want to change the keypresses, then you could always ... override ... the ... keypress ... event.

Add an event to the control like this [swaps a and o:
C#
private void richTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
    if (e.KeyChar == 'a')
    {
        e.KeyChar = 'o';
    }
    else if (e.KeyChar == 'o')
    {
        e.KeyChar = 'a';
    }
}
 
Share this answer
 
v2
Comments
smilerP 28-Apr-11 9:00am    
Thanks. I think the second idea will be more appropriate for my application because not all client machines may have hebrew keyboard. I will very much appreciate you make your idea about overriding keypress event more clearer to me so that for "q" and "x" keys I can have my desired symbols appear in the richtext box.
Nagy Vilmos 28-Apr-11 11:18am    
Added code example, vote if this helped and feel free to mark as answered if it is.
Sergey Alexandrovich Kryukov 28-Apr-11 13:08pm    
This is overly simplified, but is good to give an idea.
Also, there is much more it it -- please see my answer as well.
--SA
Nagy Vilmos 28-Apr-11 13:28pm    
I suggested using the correct keyboard as a first choice.
Sergey Alexandrovich Kryukov 28-Apr-11 14:17pm    
Sure, I agree. I only add the idea about getting a non-standard one and showing a keyboard and/or building a virtual keyboard. You should agree that this can be critical if a keyboard is non-standard.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900