Check if Caps Lock and Num Lock is on or off through Console in C#

CsharpServer Side ProgrammingProgramming

To check if Caps Lock is on or off through Console, the code is as follows −

Example

 Live Demo

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 −

 Live Demo

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
raja
Published on 11-Dec-2019 10:11:36
Advertisements