Key Down event on editor not working

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by Matt Adamson
Version: 4.0.0276
Platform: .NET 3.5
Environment: Windows Vista (64-bit)
Avatar
I capture the Key Down event to capture key presses such as Ctrl + S in the editor to perform an action. This doesn't seem to be working with the latest 276 build. I upgrade from 272 so I'm not sure which version caused this

It seems the key character being passed through is completely wrong

Comments (5)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Matt, I don't believe anything has changed in the key processing area in quite some time so I suspect it's something in your application. If you think there is a problem with SyntaxEditor then please put together a tiny sample project showing the issue and email it over. Thanks!


Actipro Software Support

Posted 11 years ago by Matt Adamson
Avatar
Great news I can reproduce this with just a simple syntax editor control on the form. However it's the KeyPress event which is behaving weird, not keydown.
       private void syntaxEditor1_KeyPress(object sender, KeyPressEventArgs e)
        {

        }
If you place a break point at the start here after pressing the Ctrl - S keys. You should see the KeyChar property value of the KeyPressEventArgs object is equal to 19 '!!' , this is what the watch window reports.
Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Matt,

KeyPress is not a good place to look for keys with modifiers pressed (like Ctrl+S). You should be using KeyDown or our SyntaxEditor.KeyTyping event for that.


Actipro Software Support

Posted 10 years ago by dharrison_ch - Zurich, Switzerland
Avatar
Hi Support gang,
I am also having this problem of how to capture (CTRL+some-other-key).
The suggestion in the previous answer does not work - eack keyboard key that gets pressed is processed seperately and strange args.KeyData values (in the KeyTyping Event Handler method).
Could you please provide some specific advice how to handle the CTRL-key sequences as an aggregated "pair".
Many thanks
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Both KeyPress and KeyDown events end up filtering down through our KeyTyping event, which is why we recomment people use Keytyping to handle keys instead.

Our control should only capture key events if there is a command binding to that key. KeyTyping lets you cancel the binding and if cancelled, will not mark it as e.Handled in KeyPress or KeyDown.

As for "chord" keys, those are tricky. Basically you'd have to ensure that no chord start key shortcut matches any of the command bindings. Either that or cancel in KeyTyping if it does.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.