On Feb 12, 10:19 am, "Kbalz" <kbalc...@edge-sweets.com> wrote:
> I have a Form that is performing a wizard-like step system (using
> TabControl), and I need a key combination (like ControlKey + A + T) to
> be caught and show a secret admin TabPage.
>
> I tried to add an event handler to the form to catch a key that I
> press and change a label to the key I press with this code:
>
> Code:
> private void AdminKeyboardEvent(object sender, KeyEventArgs e)
> {
> lblDebug.Text = e.KeyCode.ToString();
> }
>
> However I read on some other sites that my TabControl was preventing
> my Form from ever getting these key inputs.. so I had to add
> "this.KeyPreview = true;" in my Form contructor..
>
> Now my form is properly handeling a single key stroke, but how can I
> get it to handel the user press 2 or 3 keys at the same time?
>
> C#.NET 2.0 using VS2005.
This seems to work so far, Control + X
private void AdminKeyboardEvent(object sender, KeyEventArgs
e)
{
lblDebug.Text = e.KeyCode.ToString();
if (ModifierKeys.Equals(Keys.Control) &
e.KeyCode.Equals(Keys.X))
lblDebug.Text = "enter admin window";
}
|