Can I tell which keyboard a key is pressed on?

My app users have a second keyboard with special function keys. Unfortunately, the keys are mapped to buttons such as F, G, F1, etc. I would like to handle the PreviewKeyDown and prevent any keys from these keyboards that have an effect in regular controls like TextBoxes.

In WPF, is there a way to determine which keyboard raised an event?

+5
source share
2 answers

No, this is not possible in WPF.

+1
source

using System.Windows.Input, you can achieve this by capturing an event that fires in your code. The sample code below shows how this can be done in a text box.

private void SampleTextbox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete) // delete key is pressed
            {
                e.Handled = true; // Ignore key press
            }
        }
-3

All Articles