Key assignment and wdKey constants on non-US keyboards

O

Ogier

Hello out there! I've got 2½ questions:

FIRST QUESTION:

In some documents I use Greek letters and special symbols a lot. I have
therefore used the (I beleive quite standard) code shown below to insert
UNIcode characters with simple keyboard commands, like Alt-G to give a gamma
and Shift-Alt-G to produce a capital gamma:


Public Sub AssignAltKeyToMacro(MacroName As String, Key As WdKey)
KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
Command:=MacroName, KeyCode:=BuildKeyCode(wdKeyAlt, Key)
End Sub

(similar sub for ShiftAlt)

Public Sub RemoveAssignmentFromAltKey(Key)
CustomizationContext = NormalTemplate
FindKey(BuildKeyCode(wdKeyAlt, Key)).Clear
End Sub

Public Sub TypeGammaS() ' Gamma
Selection.TypeText ChrW("&H03B3") ' UNIcode hex value
End Sub

Public Sub TypeGammaC() ' Capital Gamma
Selection.TypeText ChrW("&H0393")
End Sub

Public Sub AssignGreekLetters()
CustomizationContext = NormalTemplate
...
AssignAltKeyToMacro "TypeGammaS", wdKeyG
...
AssignShiftAltKeyToMacro "TypeGammaC", wdKeyG
...
End Sub

Public Sub RemoveGreekLetters()
...
RemoveAssignmentFromAltKey wdKeyG
...
RemoveAssignmentFromShiftAltKey wdKeyG
...
End Sub


This works just fine, but is a little lengthy with ~60 Greek letters and
other symbols. Is it possible to avoid the use of the name of the subroutine
and have something like

public Sub AssignCodeToAltKey(UNIcode As String, Key As WdKey)
???
End Sub

with usage
AssignCodeToAltKey "&H03B3", wdKeyG
AssignCodeToShiftAltKey "&H0393", wdKeyG


SECOND QUESTION:

It is fairly obvious that the constant wdKeyG refers to the "G"-key of the
keyboard. But I cannot figure out which keys some other wdKeys refer to on a
non-US keyboard (mine is a Danish one).

In particular I would like to assign commands to the "½" key residing to the
left of "1" and the "<" key to the left of "Z". A US keybord has the
BackSingleQuote character left of "1", but using wdKeyBackSingleQuote has no
effect. And a US keybord has no corresponding key to the left of "Z", the "<"
key residing to the right of "M"!

Is it possible to find out which keys on a non-US keybord are connected with
which of the wdKey constants (in particular wdKeyBackSingleQuote,
wdKeyBackSlash, wdKeyOpenSquareBrace, wdKeyCloseSquareBrace, wdKeySemiColon,
wdKeySingleQuote)?


CURIOSITY QUESTION:

On a French AZERTY-keyboard, does wdKeyQ refer to "A" or "Q"?
A German keyboard has the "Y" and "Z" keys swapped. Then what about wdKeyY
and wdKeyZ?


Best wishes
Holger Nielsen
 
G

Graham Mayor

Why don't you simply install Greek language and a Greek keyboard in Windows
Regional settings. You can use the onscreen keyboard to show the key mapping
until you are familiar with them (or buy a cheap Greek / English keyboard)
and have the mapping printed on the key caps. Then all you have to do is
operate a keyboard shortcut to toggle between the languages (by default Left
ALT + Shift).

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
O

Ogier

Graham Mayor said:
Why don't you simply install Greek language and a Greek keyboard in Windows
Regional settings.

Because I only use single Greek letters as symbols in normal text, I don't
write any Greek words.
Also, I need easy acces to some mathematical symbols.

Thank you for the response
Holger
 
G

Graham Mayor

Installing the Greek keyboard doesn't stop you doing that and it is a lot
simpler than re-mapping keys, however for individual characters, I would
simply use formatted autocorrect entries (say) #a for aplha #b for beta, #d
for delta etc.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
O

Ogier

Graham Mayor said:
...however for individual characters, I would
simply use formatted autocorrect entries (say) #a for aplha #b for beta, #d
for delta etc.

That is indeed a good solution to my first problem, thank you! I'll work on
with that solution.
I have a follow-up qustion in the thread "Assigning values to an array of
records".

Also, now that I have your attention, would you please consider reading my
thread "Inserting dummy text from a macro revisited" from June 15, as I could
not get your suggestion to work.

Best wishes
Holger
 
G

Graham Mayor

I'm going out now, bit I'll have a look at these issues when I get back.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

Doug has answered your follow up question, and I have rechecked and made
some observations in the old thread.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Joined
Nov 13, 2019
Messages
2
Reaction score
0
In the communication above, I don't see an answer for the second question: It is fairly obvious that the constant wdKeyG refers to the "G"-key of the keyboard. In particular I would like to assign commands to the ">" key and the "<" key.
What are these?

The "WdKey enumeration (Word)" page does not mention "<" and ">".
I do not find it elsewhere on the net as well.

Best regards,
Thierry Hoornaert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top