0

I am working on a WinForms application that I want to visually mimic a terminal interface. The goal is for users to be able to type in commands a la Zork.

I have a textbox with an event handler on KeyDown to check whether or not the key pressed was Enter, and this part works fine. However, whenever I press "Enter", windows (the operating system) makes an audio ping. No other key press causes this sound, so I assume it's got something to do with it being, well, the "Enter" button.

What's going on here? Pressing "Enter" is pretty integral to the look and feel of what I'm developing!

Raven Dreamer
  • 6,940
  • 13
  • 64
  • 101

1 Answers1

0

You see the certain keys are special to the operating system, and so they add special effects for them, to eliminate them, you simply has to override it.

One way would be

if (e.KeyChar == 13)
{
    // This one here tells the "operation system" that the event was handled 
    // and that it needs no further handling, therefor no 'Ding'
    e.Handled = true;
}
Rainbow
  • 6,772
  • 3
  • 11
  • 28