views:

70

answers:

2

My delphi application is incompatible with native keyboards. What should I do? To explain more, first look at these pictures:

Here's an image of what an Italian keyboard looks like: http://en.wikipedia.org/wiki/Keyboard_layout#Italian

You can find the normal one (United States keyboard) in the same page.

If we press the Shift+2 (or any Shift+Number) with the normal keyboard a @ must be written but if we do it with the Italian keyboard a " must be written. But in my application, with both keyboards, it treats every keyboard as a normal keyboard! for example when I press Shift+2 within the Italian keyboard, it types @ instead of "

I'm using Delphi 7. You can test my app here: en.apadanasoftware.com/forums

Thnx in advance

+3  A: 

The characters that are sent to your Delphi application are controlled by Windows, not Delphi, the only possible exception to this is if you are intercepting the windows messages and preforming custom key handling.

If you are connecting both keyboards to the same PC, this may be caused by windows having the wrong keyboard layout loaded.

In Windows Go to "Control Panel/ Regional and Language Options" then under the Languages tab, press the Details button in the "Text services and input languages" group box, there you should be able to see what keyboard layouts you have loaded and load in new ones, if needed.

How to change your keyboard layout from Microsoft

Re0sless
A: 

Where do you receive the keyboard event in your application?

If you use a OnKeyPress event, like

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);

you will receive the key as '@': i.e. the conversion is done by Windows.

If you use a OnKeyDown event, like

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);

you'll receive the virtual key code, i.e. the raw key code, and you'll have to convert it using the Shift value.

See http://msdn.microsoft.com/en-us/library/dd375731(VS.85).aspx about virtual keys.

I guess you used OnKeyDown instead of OnKeyPress in your application.

A.Bouchez