OK, basically I want to test if the shift key is pressed.
The method i've tried (unsuccessfully) is
private bool shiftPressed = false;
private void CheckKeys(object sender, KeyPressEventArgs e)
{
//If enter is pressed and shift isn't
//This allows for line breaks in a message by pressing shift & enter at the same time
if (e.KeyChar == (char)13 && !shiftPressed)
{
//remove the line break caused by the enter key
rtbInput.Text = rtbInput.Text.Substring(0, rtbInput.Text.Length - 1);
Send();
}
//Else if shift is pressed
else if (e.KeyChar == (char)15)
{
shiftPressed = true;
}
//Else if shift is depressed
else if (e.KeyChar == (char)14)
{
shiftPressed = false;
}
}
This is run every time a key is pressed in the rich text box. Unfortunately, shift doesnt appear to trigger the KeyPressEventHandler
Can anybody show me an alternate method that i can use to test for the shift key?
Thanks,
Josh.