# Applying ShortCut Keys to Menus

Get started with Menus and Toolbars for WinForms. Create versatile menus and docking/floating toolbars. See more in documentation here.

## Content



This topic demonstrates how to use shortcut and mnemonic keys to access a menu by the keyboard instead of the mouse. You can apply shortcut and mnemonic keys to a menu item at design time or through code.

### To add a shortcut key to a menu item at design time

1.  Add a [C1MainMenu](/componentone/docs/win/online-menus-toolbar/) control to your form.
2.  Right-click the [C1MainMenu](/componentone/docs/win/online-menus-toolbar/) control, select **Edit** from its context menu, and click **Ok**. The default name for the menu is **New Command**.
3.  Right-click the **New Command** item and select **Properties** from its context menu. In the Properties window for the [C1CommandLink](/componentone/docs/win/online-menus-toolbar/), expand the **Command** node, select the [Shortcut](/componentone/docs/win/online-menus-toolbar/) property, and then select **F6** from the Shortcut list box. 
	> type=note
	> **Note**: The remaining steps are listed below for you to try and see how the short cut key functions.
4.  Add a **PictureBox** control to your form.
5.  Double-click **New Command** to create an event handler for the click event for **New Command**.
    
    Within the event handler insert code to change the back color of the **PictureBox** to violet:
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in Visual Basic
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```vbnet
    If sender Is c1CommandMenu1 Then
            Me.pictureBox1.BackColor = Color.Violet
    End If
    ```
    
    DOC-DETAILS-TAG-CLOSE
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in C#
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```csharp
    if (sender == c1CommandMenu1)
            {
                    this.pictureBox1.BackColor = Color.Violet;
            }
    ```
    
    DOC-DETAILS-TAG-CLOSE
    
6.  Run the application and press the F6 key when the form appears. The picture box appears on the form.<br />![Pcture box in forms](https://cdn.mescius.io/document-site-files/images/a27cb622-e6d9-4efc-a0b0-0c31245fd632/imagesext/image10_17.png)
    

### To add a shortcut key to a menu item programmatically

1.  In your source file locate the item in the menu where you want the shortcut key to exist.
2.  Create a shortcut key for the **C1CommmandMenu1** by entering the following code:
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in Visual Basic
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```vbnet
    Me.C1CommandMenu1.Shortcut = System.Windows.Forms.Shortcut.F6
    ```
    
    DOC-DETAILS-TAG-CLOSE
    
    DOC-DETAILS-TAG-OPEN
    
    DOC-SUMMARY-TAG-OPEN
    
    To write code in C#
    
    DOC-SUMMARY-TAG-CLOSE
    
    ```csharp
    this.C1CommandMenu1.Shortcut = System.Windows.Forms.Shortcut.F6;
    ```
    
    DOC-DETAILS-TAG-CLOSE
    

## See Also

[Localizing the Text for the Shortcut Key](/componentone/docs/win/online-menus-toolbar/menusandtoolbarsforw2/menutasks/localizingthetextfor)