C# Visual Studio扩展键处理器Alt键

C# Visual Studio扩展键处理器Alt键,c#,visual-studio,visual-studio-extensions,C#,Visual Studio,Visual Studio Extensions,无法在Alt+键上获取事件。示例Alt+E。事件触发为E和Alt,但没有Alt+E IKeyProcessorProvider中的Mb问题?我有usercontrol,希望使用内部控件ButtonKeyProc.KeyDownEvent+= [Export(typeof(IKeyProcessorProvider))] [TextViewRole(PredefinedTextViewRoles.Document)] [ContentType("any")] [Name("ButtonProvid

无法在Alt+键上获取事件。示例Alt+E。事件触发为E和Alt,但没有Alt+E
IKeyProcessorProvider中的Mb问题
?我有usercontrol,希望使用内部控件
ButtonKeyProc.KeyDownEvent+=

[Export(typeof(IKeyProcessorProvider))]
[TextViewRole(PredefinedTextViewRoles.Document)]
[ContentType("any")]
[Name("ButtonProvider")]
[Order(Before = "default")]
internal class ButtonProvider : IKeyProcessorProvider
{
    [ImportingConstructor]
    public ButtonProvider()
    {
    }

    public KeyProcessor GetAssociatedProcessor(IWpfTextView wpfTextView)
    {
        return new ButtonKeyProc(wpfTextView);
    }
}


internal class ButtonKeyProc : KeyProcessor
{
    internal static event KeyEventHandler KeyDownEvent;

    public ButtonKeyProc(ITextView textView)
    {
    }

    public override void KeyDown(KeyEventArgs args)
    {
        if (args.Key == Key.E && IsAlt)
        {
            if (KeyDownEvent != null)
            {
                KeyDownEvent(this, args);
            }
        }           
    }

    public bool IsAlt
    {
        get { return Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt); }
    }

正确的代码。需要使用args.SystemKey和Keyboard.Modifiers

public override void KeyDown(KeyEventArgs args)
{
    if (args.SystemKey == Key.E && (Keyboard.Modifiers & ModifierKeys.Alt) != 0)
    {            
    }           
}
为什么不检查一下呢?