You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> While using the **Accelerator** editor, you can right-click to display a shortcut menu of frequently used commands. The commands available depend on what the pointer is pointing to.
19
20
20
-
-[Associate an Accelerator Key with a Menu Item](../windows/associating-an-accelerator-key-with-a-menu-item.md)
21
+
> [!NOTE]
22
+
> Windows does not allow you to create empty accelerator tables. If you create an accelerator table with no entries, it is deleted automatically when you save the table.
For information on adding resources to managed projects, see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resource strings to properties, see [Creating Resource Files for Desktop Apps](/dotnet/framework/resources/creating-resource-files-for-desktop-apps). For information on globalization and localization of resources in managed apps, see [Globalizing and Localizing .NET Framework Applications](/dotnet/standard/globalization-localization/index).
> While using the **Accelerator** editor, you can right-click to display a shortcut menu of frequently used commands. The commands available depend on what the pointer is pointing to.
28
+
You can set accelerator properties in the [Properties window](/visualstudio/ide/reference/properties-window) at any time. You can also use the **Accelerator** editor to modify the accelerator properties in the accelerator table. Changes made using the **Properties** window or the **Accelerator** editor have the same result: edits are immediately reflected in the accelerator table.
29
+
30
+
### ID property
31
+
32
+
The **ID** property references each accelerator table entry in program code. This entry is the command value that the program will receive when a user presses the accelerator key or a key combination. To make an accelerator the same as a menu item, make their IDs the same (so long as the ID of the accelerator table is the same as the ID for the menu resource).
33
+
34
+
There are three properties for each accelerator ID: the **Modifier** property, the **Key** property, and the **Type** property.
35
+
36
+
#### Modifier property
37
+
38
+
The **Modifier** property sets control key combinations for the accelerator.
39
+
40
+
> [!NOTE]
41
+
> In the **Properties** window, this property appears as three separate **Boolean** properties, all of which can be controlled independently: **Alt**, **Ctrl**, and **Shift**.
42
+
43
+
The following are legal entries for the **Modifier** property in the accelerator table:
44
+
45
+
|Value|Description|
46
+
|-----------|-----------------|
47
+
|**None**|User presses only the **Key** value. This value is most effectively used with the ASCII/ANSI values 001 through 026, which is interpreted as ^A through ^Z (**Ctrl+A** through **Ctrl+Z**).|
48
+
|**Alt**|User must press the **Alt** key before the **Key** value.|
49
+
|**Ctrl**|User must press the **Ctrl** key before the **Key** value. Not valid with ASCII Type.|
50
+
|**Shift**|User must press the **Shift** key before the **Key** value.|
51
+
|**Ctrl+Alt**|User must press the **Ctrl** key and the **Alt** key before the **Key** value. Not valid with ASCII Type.|
52
+
|**Ctrl+Shift**|User must press the **Ctrl** key and the **Shift** key before the **Key** value. Not valid with ASCII Type.|
53
+
|**Alt+Shift**|User must press the **Alt** key and the **Shift** key before the **Key** value. Not valid with ASCII Type.|
54
+
|**Ctrl+Alt+Shift**|User must press **Ctrl**, **Alt**, and **Shift** before the **Key** value. Not valid with ASCII Type.|
55
+
56
+
#### Key property
57
+
58
+
The **Key** property sets the actual key to use as the accelerator.
59
+
60
+
The following are legal entries for the **Key** property in the accelerator table:
61
+
62
+
|Value|Description|
63
+
|-----------|-----------------|
64
+
|An integer between 0 and 255 in decimal format.|The value determines whether the value is treated as ASCII or ANSI as follows:<br/><br/>- Single-digit numbers are always interpreted as the corresponding key, rather than as ASCII or ANSI values.<br/>- Values from 1 through 26, when preceded with zeros, are interpreted as ^A through ^Z, which represents the ASCII value of the letters of the alphabet when pressed with the **Ctrl** key held down.<br/>- Values from 27-32 are always interpreted as three-digit decimal values 027 through 032.<br/>- Values from 033 through 255, whether preceded by 0's or not are interpreted as ANSI values.|
65
+
|A single keyboard character.|Uppercase A - Z or the numbers 0 - 9 can be either ASCII or virtual key values; any other character is ASCII only.|
66
+
|A single keyboard character in the range A - Z (uppercase only), preceded by a caret (^) (for example, ^C).|This option enters the ASCII value of the key when it's pressed with the **Ctrl** key held down.|
67
+
|Any valid virtual key identifier.|The drop-down Key box in the Accelerator table contains a list of standard virtual key identifiers.|
68
+
69
+
> [!NOTE]
70
+
> When entering an ASCII value, the modifier property options are limited. The only control key available for use is the **Alt** key.
71
+
72
+
> [!TIP]
73
+
> Another way to define an accelerator key is to right-click an entry or multiple entries in the Accelerator table, choose **Next Key Typed** from the shortcut menu, and then press any of the keys or key combinations on the keyboard. The **Next Key Typed** command is also available from the **Edit** menu.
74
+
75
+
#### Type property
76
+
77
+
The **Type** property determines whether the shortcut key combination associated with the accelerator ID is interpreted as an ASCII/ANSI key value or a virtual key (VIRTKEY) combination.
78
+
79
+
- If the **Type** property is ASCII, the **Modifier** property may only be `None` or `Alt`, or it can have an accelerator that uses the **Ctrl** key (specified by preceding the key with a `^`).
80
+
81
+
- If the **Type** property is VIRTKEY, any combination of `Modifier` and `Key` values is valid.
82
+
83
+
> [!NOTE]
84
+
> If you want to enter a value into the accelerator table and have the value be treated as ASCII/ANSI, simply click the **Type** for the entry in the table and select ASCII from the drop down list. However, if you use the **Next Key Typed** command (**Edit** menu) to specify the `Key`, you must change the **Type** property from VIRTKEY to ASCII *before* entering the `Key` code.
85
+
86
+
## Accelerator tables
87
+
88
+
In a C++ project, you can edit an accelerator table directly with in-place editing in the **Accelerator** editor.
89
+
90
+
The procedures below refer to the use of standard property pages, however, both in-place editing and the property page method have the same result. Changes made using property pages or using in-place editing are immediately reflected in the accelerator table.
91
+
92
+
> [!NOTE]
93
+
> If your project doesn't already contain an .rc file, please see [Creating a New Resource Script File](../windows/how-to-create-a-resource-script-file.md).
94
+
95
+
### To edit in an accelerator table
96
+
97
+
1. Open the accelerator table by double-clicking its icon in [Resource View](../windows/resource-view-window.md).
98
+
99
+
1. Select an entry in the table and select to activate in-place editing.
100
+
101
+
1. Select from the drop-down combo box or type in place to make changes.
102
+
103
+
- For **ID**, select from the list or type to edit.
104
+
105
+
- For **Modifier**, select from the list.
106
+
107
+
- For **Key**, select from the list or type to edit.
108
+
109
+
- For **Type**, select **ASCII** or **VIRTKEY** from the list.
110
+
111
+
### To find an entry in an open accelerator table
112
+
113
+
1. Open the accelerator table by double-clicking its icon in [Resource View](../windows/resource-view-window.md).
114
+
115
+
1. Select a column head to sort the contents of the column alphabetically. For example, select **ID** to display all the IDs in your accelerator table alphabetically.
116
+
117
+
You can then scan the list and find the entry.
118
+
119
+
### To add an entry to an accelerator table
120
+
121
+
1. Open the accelerator table by double-clicking its icon in [Resource View](../windows/resource-view-window.md).
122
+
123
+
1. Right-click within the accelerator table and choose **New Accelerator** from the shortcut menu, or select the empty row entry at the bottom of the table.
124
+
125
+
1. Select an **ID** from the drop-down list in the ID box or type a new ID in the **ID** box.
126
+
127
+
1. Type the **Key** you want to use as an accelerator or right-click and choose **Next Key Typed** from the shortcut menu to set a key combination (the **Next Key Typed** command is also available from the **Edit** menu).
128
+
129
+
1. Change the **Modifier** and **Type**, if necessary.
130
+
131
+
1. Press **Enter**.
28
132
29
133
> [!NOTE]
30
-
> Windows does not allow you to create empty accelerator tables. If you create an accelerator table with no entries, it is deleted automatically when you save the table.
134
+
> Make sure all accelerators you define are unique. You can have several key combinations assigned to the same ID with no ill effect, for example, **Ctrl** + **P** and **F8** can both be assigned to ID_PRINT. However, having a key combination assigned to more than one ID will not work well, for example, **Ctrl** + **Z** assigned to both ID_SPELL_CHECK and ID_THESAURUS.
135
+
136
+
### To delete an entry from an accelerator table
137
+
138
+
1. Open the accelerator table by double-clicking its icon in [Resource View](../windows/resource-view-window.md).
31
139
32
-
For information on adding resources to managed projects, please see [Resources in Desktop Apps](/dotnet/framework/resources/index) in the *.NET Framework Developer's Guide*. For information on manually adding resource files to managed projects, accessing resources, displaying static resources, and assigning resource strings to properties, see [Creating Resource Files for Desktop Apps](/dotnet/framework/resources/creating-resource-files-for-desktop-apps). For information on globalization and localization of resources in managed apps, see [Globalizing and Localizing .NET Framework Applications](/dotnet/standard/globalization-localization/index).
140
+
1. Select the entry you want to delete. (Hold down the **Ctrl** or **Shift** key while selecting to choose multiple entries.)
141
+
142
+
1. Right-click and choose **Delete** from the shortcut menu (or select **Delete** from the **Edit** menu).
143
+
144
+
> [!TIP]
145
+
> A shortcut for delete is to press the **Delete** key.
146
+
147
+
### To move or copy an accelerator table entry to another resource script file
148
+
149
+
1. Open the accelerator tables in both resource script files.
150
+
151
+
1. Select the entry you want to move.
152
+
153
+
1. From the **Edit** menu, choose **Copy** or **Cut**.
154
+
155
+
1. Select an entry in the target resource script file.
156
+
157
+
1. From the **Edit** menu, choose **Paste**.
158
+
159
+
> [!NOTE]
160
+
> You can also use the shortcut keys for copying and pasting.
161
+
162
+
### To change the properties of multiple accelerator keys
163
+
164
+
1. Open the accelerator table by double-clicking its icon in [Resource View](../windows/resource-view-window.md).
165
+
166
+
1. Select the accelerator keys you want to change by holding down the **Ctrl** key as you select each one.
167
+
168
+
1. Go to the [Properties window](/visualstudio/ide/reference/properties-window) and type in the values you want all of the selected accelerators to share.
169
+
170
+
> [!NOTE]
171
+
> Each modifier value appears as a Boolean property in the **Properties** window. If you change a [Modifier](../windows/accelerator-modifier-property.md) value in the **Properties** window, the accelerator table treats the new modifier as an addition to any modifiers that were previously there. Because of this, if you set any modifier values, you will need to set all of them to ensure that every accelerator shares the same **Modifier** settings.
0 commit comments