is there any other way besides

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.B)
            {
                MessageBox.Show("Enter pressed!");
                String fileName = @"C:/Windows/Media/tada.wav";
                PlaySound(fileName, 0, 1);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

that to capture key presses i want to beable to capture more than one. for example in my app if you press O the cd tray opens. i want to be aable to press C and it close but for some reason when i try to put that code in there again it gives me an error

any on ideas on code that ould let me do this would be helpful

thankyou

tayspen

Edited 4 Years Ago by Dani: Fixed formatting

Hope this helps

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
		{ 
			bool result = false;
			switch (keyData)
			{
				case(Keys.B):
					MessageBox.Show("Enter pressed!");
					String fileName = @"C:/Windows/Media/tada.wav";
					PlaySound(fileName, 0, 1);
					result = true;
					break;
				case(Keys.O):
					//code to open cd tray here
					result = true;
					break;
				case(Keys.C):
					//code to close cd tray here
					result = true;
					break;
			}
			return result;		}
This article has been dead for over six months. Start a new discussion instead.