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

CsharpServer Side ProgrammingProgramming

<p style="">To check if Caps Lock is on or off through Console, the code is as follows &minus;</p><h2>Example</h2><p><a class="demo" href="http://tpcg.io/cFW1VRwQ" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate" style="">using System; public class Demo{ &nbsp; &nbsp;public static void Main(string[] args){ &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;The CAPS LOCK is on or not? &quot;+ Console.CapsLock); &nbsp; &nbsp;} }</pre><h2>Output</h2><p>This will produce the following output &minus;</p><pre class="result notranslate">The CAPS LOCK is on or not? False</pre><h2>Example</h2><p>To check if Num Lock is on or off through Console, the code is as follows &minus;</p><p><a class="demo" href="http://tpcg.io/EySiNPtz" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate" style="">using System; public class Demo{ &nbsp; &nbsp;public static void Main(string[] args){ &nbsp; &nbsp; &nbsp; Console.WriteLine(&quot;The Num LOCK is on or not? &quot;+ Console.NumberLock); &nbsp; &nbsp;} }</pre><h2>Output</h2><p>This will produce the following output &minus;</p><pre class="result notranslate">The Num LOCK is on or not? True</pre>
raja
Updated on 11-Dec-2019 05:43:22

Advertisements