Check Caps Lock and Num Lock Status in C# Console



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
Updated on: 2019-12-11T05:43:22+05:30

336 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements