Are some keyboards more talkative than others?

The lead developer says that when he uses my application, his keyboard beeps when he moves between TextBoxes on the TableLayoutPanel using the direction arrow keys.

However, I do not hear such auditory activity.

Here is my code:

// Had to intercept Up and Down arrows from Windows private void textBoxPlatypi_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { TextBox tb = (TextBox)sender; if (e.KeyCode.Equals(Keys.Up)) { SetFocusOneRowUp(tb.Name); return; } if (e.KeyCode.Equals(Keys.Down)) { SetFocusOneRowDown(tb.Name); return; } } private void textBoxPlatypi_KeyDown(object sender, KeyEventArgs e) { TextBox tb = (TextBox)sender; if (e.KeyCode.Equals(Keys.Left)) { SetFocusOneColumnBack(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Right)) { SetFocusOneColumnForward(tb.Name); e.Handled = true; return; } } 

.. He thought maybe I need "e.Handled", but this is not available in the PreviewKeyDown event.

Is there a way to suppress the beep (which apparently only happens with some keyboards or certain settings (it uses Windows7, I'm still on XP)?

UPDATE

I have this code now:

 private void textBoxPlatypus1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { switch (e.KeyCode) { case Keys.Down: case Keys.Up: e.IsInputKey = true; break; } } private void textBoxPlatypus1_KeyDown(object sender, KeyEventArgs e) { TextBox tb = (TextBox)sender; if (e.KeyCode.Equals(Keys.Up)) { SetFocusOneRowUp(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Down)) { SetFocusOneRowDown(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Left)) { SetFocusOneColumnBack(tb.Name); e.Handled = true; return; } if (e.KeyCode.Equals(Keys.Right)) { SetFocusOneColumnForward(tb.Name); e.Handled = true; return; } } 

... but he still hears a beep (I do not).

He is in Alaska and uses Windows 7; I am in California and am using XP. I don't know if there is any combination / inconsistency of the problem ...

UPDATED AGAIN

I know this can be shocking to some, but disabling Alaska / California has nothing to do with it. Now I hear beeps, and this is not from the arrow keys. This is when the value is entered into the TextBox, and then, if there is already a character in this text box, the focus moves to the next text block, and the value is entered here (this is my code that calls it). But the annoying beep sounds random - I didn't understand the pattern when it beeps (sometimes it happens, sometimes it doesn't) ... has anyone ever come across anything like that or, better yet, knows how to suppress sound signal? All I do is press the "1" or "2" key above the keyboard.

+7
source share
2 answers

In PreviewKeyDownEvent, there is no way to handle / block a KeyEvent, as in a regular KeyDown event. The suggested documentation is to set the PreviewKeyDownEventArgs.IsInputKey property to true to handle keystrokes that are normally not available in the KeyDown event.

At the top of the link, they use the button as an example:

Some keystrokes, such as the TAB, RETURN, ESC, and arrow keys, are usually ignored by some controls because they are not considered input keystrokes ... When you handle the PreviewKeyDown event for a button and set the IsInputKey property to true, you can raise the KeyDown event when you press the arrow keys. However, if you process the arrow keys, the focus will no longer move to the previous or next control.

+3
source

Try this :

  e.SuppressKeyPress = true; 
+1
source

All Articles