Syntax
ToolsCustomizeKeyboard [.KeyCode = number] [, .KeyCode2 = number] [, .Category = number] [, .Name = text] [, .Add] [, .Remove] [, .ResetAll] [, .CommandValue = text] [, .Context = number]
Remarks
Assigns and reassigns shortcut keys to built-in commands, macros, fonts, AutoText entries, styles, or common symbols. The arguments for the ToolsCustomizeKeyboard statement correspond to the options on the Keyboard tab in the Customize dialog box (Tools menu).
Argument | Explanation | |
.KeyCode | A number representing the key combination, as listed later in this entry. | |
.KeyCode2 | A number representing the second key combination in a key sequence. For example, to assign the key sequence CTRL+S, 1 (on the Macintosh, COMMAND+S, 1) to the Heading 1 style, you set .KeyCode to 339 (for CTRL+S or COMMAND+S) and .KeyCode2 to 49 (for 1). | |
.Category | Specifies the kind of item to assign a shortcut key: 1 or omitted Built-in commands 2 Macros 3 Fonts 4 AutoText entries 5 Styles 6 Common symbols |
Argument | Explanation | |
.Name | The name of the command, macro, or other item. If .Category is set to 6, you can specify a symbol by typing or pasting it into the macro-editing window or using a Chr$() instruction such as Chr$(167). | |
.Add | Adds the key assignment or assignments to the specified item. | |
.Remove | If the specified key code is currently assigned, removes the assignment such that the associated key combination has no effect. If the specified key code is not assigned, .Remove resets the key code to its default action. Note that specifying .Name is not required when removing or resetting a key assignment. | |
.ResetAll | Resets all key assignments to their defaults. | |
.CommandValue | Additional text required for the command specified by .Name, if any. For example, if .Name is set to Color, .CommandValue specifies the color. For more information, see the table of settings for .CommandValue in ToolsCustomizeMenus. | |
.Context | Determines where new key assignments are stored: 0 (zero) or omitted Normal template 1 Active template |
The following tables list the values you need to specify the appropriate number for .KeyCode. The first table contains values you add to values in the second table when specifying a key combination (for example, you would specify CTRL+S (on the Macintosh, COMMAND+S) as the sum of 256 and 83, or 339).
Add this | To combine with this key | |
256 | CTRL (Windows) or COMMAND (Macintosh) | |
512 | SHIFT | |
1024 | ALT (Windows) or OPTION (Macintosh) | |
2048 | CONTROL (Macintosh) |
In Windows, function keys F11 through F16 are equivalent to Alt+F1 through Alt+F6. Therefore, the key code corresponding to F11 has the same effect as a key code corresponding to Alt+F1. Similarly, specifying Alt+F11 — effectively Alt+Alt+F1 — is no different from specifying alt+F1.
This key code | Corresponds to | |
8 | BACKSPACE | |
9 | TAB | |
12 | 5 on the numeric keypad when Num Lock is off | |
13 | ENTER | |
19 | Pause |
This key code | Corresponds to | |
27 | ESC | |
32 | SPACEBAR | |
33 | PAGE UP | |
34 | PAGE DOWN | |
35 | END | |
36 | HOME | |
45 | INS | |
46 | DEL | |
48 | 0 | |
49 | 1 | |
50 | 2 | |
51 | 3 | |
52 | 4 | |
53 | 5 | |
54 | 6 | |
55 | 7 | |
56 | 8 | |
57 | 9 | |
65 | A | |
66 | B | |
67 | C | |
68 | D | |
69 | E | |
70 | F | |
71 | G | |
72 | H | |
73 | I | |
74 | J | |
75 | K | |
76 | L | |
77 | M | |
78 | N | |
79 | O | |
80 | P |
This key code | Corresponds to | |
81 | Q | |
82 | R | |
83 | S | |
84 | T | |
85 | U | |
86 | V | |
87 | W | |
88 | X | |
89 | Y | |
90 | Z | |
96 | 0 on the numeric keypad | |
97 | 1 on the numeric keypad | |
98 | 2 on the numeric keypad | |
99 | 3 on the numeric keypad | |
100 | 4 on the numeric keypad | |
101 | 5 on the numeric keypad | |
102 | 6 on the numeric keypad | |
103 | 7 on the numeric keypad | |
104 | 8 on the numeric keypad | |
105 | 9 on the numeric keypad | |
106 | * on the numeric keypad | |
107 | + on the numeric keypad | |
109 | – on the numeric keypad | |
110 | . on the numeric keypad | |
111 | / on the numeric keypad | |
112 | F1 | |
113 | F2 | |
114 | F3 | |
115 | F4 | |
116 | F5 | |
117 | F6 | |
118 | F7 | |
119 | F8 | |
120 | F9 |
This key code | Corresponds to | |
121 | F10 | |
122 | F11 | |
123 | F12 | |
124 | F13 | |
125 | F14 | |
126 | F15 | |
127 | F16 | |
145 | Scroll Lock | |
186 | ; | |
187 | = | |
188 | , | |
189 | - | |
190 | . | |
191 | / | |
192 | ` | |
219 | [ | |
220 | \ | |
221 | ] | |
222 | ' |
Examples
This example assigns CTRL+SHIFT+F (Windows) or command+SHIFT+F (Macintosh) to FileFind:
ToolsCustomizeKeyboard .Category = 1, .Name = "FileFind", \ .KeyCode = 838, .Add
The following example removes the key assignment from FileFind:
ToolsCustomizeKeyboard .Category = 1, .Name = "FileFind", \ .KeyCode = 838, .Remove
See Also
CountKeys(), KeyCode(), KeyMacro$()