To check if Caps Lock is on or off through Console, the code is as follows −
Example
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("The CAPS LOCK is on or not? "+ Console.CapsLock);
}
}Output
This will produce the following output −
The CAPS LOCK is on or not? False
Example
To check if Num Lock is on or off through Console, the code is as follows −
using System;
public class Demo{
public static void Main(string[] args){
Console.WriteLine("The Num LOCK is on or not? "+ Console.NumberLock);
}
}Output
This will produce the following output −
The Num LOCK is on or not? True