要通过控制台检查Caps Lock是打开还是关闭,代码如下-
using System; public class Demo{ public static void Main(string[] args){ Console.WriteLine("The CAPS LOCK is on or not? "+ Console.CapsLock); } }
输出结果
这将产生以下输出-
The CAPS LOCK is on or not? False
要通过控制台检查Num Lock是打开还是关闭,代码如下-
using System; public class Demo{ public static void Main(string[] args){ Console.WriteLine("The Num LOCK is on or not? "+ Console.NumberLock); } }
输出结果
这将产生以下输出-
The Num LOCK is on or not? True