This is a migrated thread and some comments may be shown as answers.

Keyboard (KeyDown/Up/Press/...) Events?

2 Answers 134 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Jörg B.
Top achievements
Rank 1
Jörg B. asked on 28 Feb 2011, 03:08 PM
Hello there,

I had a quick look at the Silverlight documentation (is the WPF RichTextBox (beta) Documentation available already somewhere?) and I did not see any Events being mentioned regarding key events, as in e.g. whenever the user enters a key in the editor indicate what key(s) was/were pressed (or e.g. what combo like alt+shift+f etc). Is anything like that available/possible or planned for the editor?

Best regards,
-Jörg B.

2 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 03 Mar 2011, 01:13 PM
Hi Jörg B.,

There is still not any documentation of the WPF version of RadRichTextBox, but you have guessed right that most of the things that are described in the documentation for the Silverlight control also apply to the WPF one.
As for the Key events you have mentioned, RadRichTextBox inherits them from System.Windows.UIElement and should work just as they do for all WPF controls. Here is an example of how you can get the pressed Keys on KeyDown:

Copy Code
private void editor_KeyDown(object sender, KeyEventArgs e)
{
    ModifierKeys modifiers = e.KeyboardDevice.Modifiers;
 
    if ((modifiers & ModifierKeys.Shift) != 0 && (modifiers & ModifierKeys.Control) != 0)
    {
        MessageBox.Show("Shift and Control are pressed!");
    }
    //if (modifiers.HasFlag(ModifierKeys.Shift) && modifiers.HasFlag(ModifierKeys.Control))
    //{
    //    MessageBox.Show("Shift and Control are pressed!");
    //}
}

I have listed two options and commented out the second. You can choose which one fits your taste better.

Greetings,
Iva
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Jörg B.
Top achievements
Rank 1
answered on 03 Mar 2011, 03:09 PM
Great to hear - thanks!
Tags
RichTextBox
Asked by
Jörg B.
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Jörg B.
Top achievements
Rank 1
Share this question
or