How can I ignore/block/remove the Ctrl–L keyboard shortcut from a WPF RichTextBox?
Right-now, this is bound to the AlignLeft EditingCommand. I’d like to use this keyboard shortcut for something else (delete line) in the RichTextBox.
I’m currently handling the keyDown event, but Ctrl–L never makes it through. In other words, I can respond to Ctrl–H, for example, no problem, but Ctrl–L is already gobbled up by the control.
private void richTextBoxMain_KeyDown (object sender, KeyEventArgs e)
{
if ( Keyboard.IsKeyDown(Key.LeftCtrl))
{
if (e.Key == Key.L)
{
// never gets here.
}
}
}
Add this in your page load method (or somewhere suitable)
That will prevent
CTRL + Lfrom invoking the command it usually does (due to theNotACommandenum). The code you currently have in yourKeyDownmethod should now work.