Basically i am trying to make a program that can handle keyboard events, but it keeps spitting out the error.
cannot assign to 'keydown' because it is a 'method group'
The error
Form1.Keypress(object, KeyPressEventsArg)' hides inherited method 'Control.KeyPress'. Use the new Keboard if hiding was intended
The Two Programs i used were
private void KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
{
MessageBox.Show("Enter Key Pressed");
}
}
private void KeyUp(object sender, KeyEventArgs e)
{
}
private void KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == (char)Keys.Enter)
{
MessageBox.Show("Enter was pressed");
}
}
The other one was
private new void KeyDown(object sender, KeyEventArgs e)
{
Input.ChangedState(e.KeyCode, true);
}
private new void KeyUp(object sender, KeyEventArgs e)
{
Input.ChangedState(e.KeyCode, false);
}
public static Hashtable KeyBoard = new Hashtable();
public static bool KeyPressed(Keys key)
{
if (KeyBoard[key] == null)
{
return false;
}
else
{
return (bool)KeyBoard[key];
}
}
public static void ChangedState(Keys key, bool state)
{
KeyBoard[key] = state;
}
What I have tried:
I tried using the solutions vs provided but none of them work