Replies: 2 comments 2 replies
-
|
Right now, this is what my Window code looks like (just while I'm trying to get this working as expected): public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Key == Key.Space && !e.Handled)
{
Console.WriteLine($"Space Down / {e.Route}");
e.Handled = true;
}
}
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if (e.Key == Key.Space && !e.Handled)
{
Console.WriteLine($"Space Up / {e.Route}");
e.Handled = true;
}
}
}and the result I get when I simply hold the Spacebar down: This reads to me like it's going by the expected behavior for keyboard text input. But I just want to know simply if the key has been pressed down or released up, similar to |
Beta Was this translation helpful? Give feedback.
-
|
Abstracting mouse, touch and pen events is hard and sometimes creates difficulties. (MacOS has a similar API) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey folks!
I'm trying to make an application that keeps track of key and button states: are they currently pressed or released? Seems like a very simple thing: I implement
protected override void OnKeyDown(KeyEventArgs e)andOnKeyUpon my window, create a boolean that turns on when OnKeyDown's e.Key is Space, turns the bool off when OnKeyUp is Space. Simple.But what happens is I get repeating, alternating Space Up/Space Down signals.
What is the intended workflow to get a keyboard key's IsCurrentlyDown state?
Beta Was this translation helpful? Give feedback.
All reactions