welcome to my space

March
14
Posted by: admin on March 14th, 2010    Filled in: enart.cgkq.com
  • Hi, I am hoping to get some ideas on how to achieve the following..

    I am trying to capture multiple keydowns in order to execute certain event..

    I'm using WPF and C#... I've tried the following to test... it doesn't work, so I am hoping to get some ideas...


    private void test(object sender, System.Windows.Input.KeyEventArgs e)
    {
    if (e.Key == System.Windows.Input.Key.H && e.Key == System.Windows.Input.Key.LeftCtrl
    && e.Key == System.Windows.Input.Key.System)
    {
    MessageBox.Show("Key pressed is: " + e.Key);
    }
    }



    I am basically trying to capture Ctrl+Alt+h..


  • i havent c#, but i think you could use the "get asynckeystate"


  • The reason that your code is not working is that e.Key only references the most recently pressed key, so it can't be equal to 3 different keys at once.

    If nothing else, couldn't you maintain a list/array of the currently pressed keys? You could update the list with handlers for KeyUps and KeyDowns and figure out whether a certain combination of keys was pressed by iterating through the array. I'm not sure if there is built-in functionality to do this, but it would be easy enough to implement.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about multiple keydown captures , Please add it free.