Currently, I have this:
if ((input.Text.ToUpper() == "FURNACE" || input.Text.ToUpper() == "COAL") && count == 3)
{
end3();
}
else
{
MessageBox.Show("Unknown key");
}
However, no matter if I enter FURNACE, COAL, or anything else, it still pops up with “Unknown key”. Why?
It’s under a KeyUp event, like this:
private void input_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Enter)
{
//The earlier code I showed goes here
}
}
Count varies, one of the if (input.Text.ToUpper…) is adding one to count, but it starts at zero.
Input is a textbox.
I think that you are missing
e.SuppressKeyPress = true;right after you enter to theifso when you press enter it will not appear as char in your text.