Software Development Network>> Visual C#>> 'esc' key ?????????
Hi,
not sure how your program works exactly, but see if you find the following piece of code helpful:
static void Main(string[] args){ Console.WriteLine("Waiting for escape key..."); while (true) { ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) { break; } }}
Andrej
ahmedilyas wrote: no offense V.Tortola ! :-)
no offense V.Tortola ! :-)
Yes, that's possible, by key interception. Try the following code:
the last one would be a better solution than checking the actual key code value :-) It's better to do it the .NET way
In a TextBox, config the PasswordChar to a asterisk ;)
Regards.
thank you...
this is the code that i'm going to use:
once again thank's..
Great work!!! :)
thanks....
In the key press event of the main form ...
'esc' key ?????????
tgbt
Hi,
not sure how your program works exactly, but see if you find the following piece of code helpful:
static void Main(string[] args)
{
Console.WriteLine("Waiting for escape key...");
while (true)
{
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key == ConsoleKey.Escape)
{
break;
}
}
}
Andrej
millertime408
Don't worry, learn new and/or more efficient ways is always wellcome :D
Regards.
NiklasECG2
Yes, that's possible, by key interception. Try the following code:
static void Main(string[] args){
Console.WriteLine("Type your password and press ENTER...");
StringBuilder passwordBuilder = new StringBuilder();
while (true)
{
ConsoleKeyInfo key = Console.ReadKey(true);
if (key.Key == ConsoleKey.Enter)
{
Console.WriteLine("\r\nYour password: " + passwordBuilder.ToString());
Console.ReadKey();
break;
}
passwordBuilder.Append(key.KeyChar);
Console.Write("*");
}
}
Andrej
HCTwinJava
the last one would be a better solution than checking the actual key code value :-) It's better to do it the .NET way
no offense V.Tortola ! :-)
Fwank79
Dr.Virusi
In a TextBox, config the PasswordChar to a asterisk ;)
Regards.
Greg Leininger
thank you...
this is the code that i'm going to use:
Console.WriteLine("\t\tPress Esc to exit or ENTER to continue"); ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.Escape) Environment.Exit(-1);once again thank's..
ly4587
Great work!!! :)
thanks....
Luis Neves
In the key press event of the main form ...
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)27) Application.Exit();
}
Regards.