Andrew Critchley
Andrew Critchley

Reputation: 123

C# Keyboard mappings

I am trying to create an on screen keyboard in WPF, however I've gotten stuck on a programatic way to map the non-alpha keys to their shifted equivalent, for example:

1 becomes ! 2 becomes " 3 becomes £

etc, for if possible, the current culture, or if not the UK Layout.

Any help would be appreciated, thank you!

Upvotes: 3

Views: 1465

Answers (1)

Jodrell
Jodrell

Reputation: 35716

You need to interrogate the keyboard map as described in this answer.

This way you can get the charachter for all modifiers on your current map or another map.

The post describes how to use the ToAscii WinAPI, you can use the results to "modify" the display of your keyboard. Use ToAsciiEx for other keyboard maps.

This doesen't help you with what I think is a rather more difficult problem of how to layout the keyboard, touched on by this wikipedia article.

However, if you are going for a standardised tablet friendly approach you have probably dealt with this and, in fact, the localization of the user may be irrelavent.

Upvotes: 1

Related Questions