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


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: 11-Dec-2019

259 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements