Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know when ctrl+space pushed?

Tags:

c#

wpf

textbox

I want to call function when Ctrl+space pushed. I searched more but couldn't find what I want.

like image 910
Javidan Guliyev Avatar asked Feb 23 '26 23:02

Javidan Guliyev


2 Answers

You need to add an event handler for KeyDown like: KeyDown="TextBox_KeyDown" on your TextBox. And then in the event handler:

if (e.Key == Key.Space && e.KeyboardDevice.Modifiers == ModifierKeys.Control)
{ 
      //Do Stuff
}
like image 89
Adrian Fâciu Avatar answered Feb 25 '26 11:02

Adrian Fâciu


Use something like this:

private void Window_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Space && 
       (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
    {
        // Do what you need here
    }
}
like image 34
Marco Avatar answered Feb 25 '26 13:02

Marco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!