flopoloco's picture

How to get KeyPressEventArgs?

Do you know a good way to get KeyPressEventArgs?

In this case I would convert the KeyChar integer but it's rather hardcoded way to do.

win.KeyPress += (object sender, KeyPressEventArgs e) => {
	if ((int)e.KeyChar == 27)


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
winterhell's picture

What are you trying to do, compare directly with the OpenTK.Input.Key enums?

If your class inherits GameWindow you can simply call
if (Keyboard[Key.Escape]) Exit();

Or alternatively init your own KeyboardDevice and repeat the above.

Of course if you have a rendering loop and not just repaint on event then you can dismiss the key event altogether.

the Fiddler's picture