XNA supports only English keyboards, so I want to use System.Windows.Forms's KeyPress event. But I can't. Why?
I tried my own codes:
// 1st
FromHandle(Window.Handle).FindForm().KeyPress += new System.Windows.Forms.KeyPressEventHandler(KeyPressEvent);
// 2nd
FromHandle(Window.Handle).FindForm().KeyPress += KeyPressEvent;
After I found and tried a solution from stackoverflow:
using System.Windows.Forms; ... var form = (Form)Form.FromHandle(window.Handle); form.KeyPress += form_KeyPress; ... private void form_KeyPress(Object sender, KeyPressEventArgs e) { Console.WriteLine(e.KeyChar); e.Handled = true; }
I tried these solutions in a new, empty C# XNA project, too, but none of them worked. What have I done wrong?