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

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;		}

yup exactley what i was looking for thank you very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.