This document is archived and information here might be outdated.  Recommended version.


IAccelerator.Key Property (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Framework > ESRI.ArcGIS.Framework > Interfaces > IA > IAccelerator Interface > IAccelerator.Key Property
ArcGIS Developer Help

IAccelerator.Key Property

The keycode for this accelerator.

[Visual Basic .NET]
Public Property Key As Integer
[C#]
public int Key {get; set;}

Product Availability

Available with ArcGIS Desktop.
[C#]

Use the System.Windows.Forms.Keys enum for the value of Key and convert it into an integer.

public void AcceleratorKey(IDocument document)
{
    //Get the command ID that correspond to Ctrl-C (e.g. File.Copy)
    int keyC = (int)System.Windows.Forms.Keys.C;
    IAccelerator acc = document.Accelerators.FindByKey(keyC, true, false, false);
    if (acc != null)
    {
        UID commandID = acc.CommandID as UID;
        Debug.WriteLine(commandID.Value);
        Debug.WriteLine(acc.Key);
        Debug.WriteLine((System.Windows.Forms.Keys)acc.Key);
        //Output
        //{A33D9405-7ED5-11D0-8D7C-0080C7A4557D}
        //67
        //C
    }
}

 

[Visual Basic .NET]

Use the System.Windows.Forms.Keys enum for the value of Key and convert it into an integer.

Sub AcceleratorKey(document As IDocument)
    ' Get the command ID that correspond to Ctrl-C (e.g. File.Copy)
    Dim keyC As Integer = Convert.ToInt32(System.Windows.Forms.Keys.C)
    Dim acc As IAccelerator = document.Accelerators.FindByKey(keyC, True, False, False)
    If Not acc Is Nothing Then
        Dim commandID As UID = CType(acc.CommandID, UID)
        Debug.WriteLine(commandID.Value)
        Debug.WriteLine(acc.Key)
        Debug.WriteLine(CType(acc.Key, System.Windows.Forms.Keys))
        ' Output
        '{A33D9405-7ED5-11D0-8D7C-0080C7A4557D}
        '67
        'C
    End If
End Sub

See Also

IAccelerator Interface