Csharp/C Sharp by API/System/ConsoleModifiers
Версия от 15:31, 26 мая 2010; (обсуждение)
ConsoleModifiers.Alt
using System;
using System.Collections.Generic;
class MainClass
{
public static void Main()
{
ConsoleKeyInfo key;
List<char> input = new List<char>();
do{
key = Console.ReadKey(true);
if (key.Key == ConsoleKey.F1)
{
Console.WriteLine("F1");
}
if (key.Key == ConsoleKey.Backspace)
{
if (input.Count > 0)
{
input.RemoveAt(input.Count - 1);
Console.Write(key.KeyChar);
}
}else if (key.Key == ConsoleKey.Escape){
Console.Clear();
Console.WriteLine("Input: {0}\n\n",new String(input.ToArray()));
input.Clear();
}else if (key.Key >= ConsoleKey.A && key.Key <= ConsoleKey.Z){
input.Add(key.KeyChar);
Console.Write(key.KeyChar);
}
} while (key.Key != ConsoleKey.X || key.Modifiers != ConsoleModifiers.Alt);
}
}