How to detect if my capslock is activate in keyboard using c# ?
Event.capsLock as seen here: Unity - Scripting API: Event.capsLock
Not working
Hmmm… Try using the code suggested by quicktom here: Unable to trace CapsLock toggle on and off - Questions & Answers - Unity Discussions
He wrote:
using System.Runtime.InteropServices;
[DllImport("user32.dll")]
public static extern short GetKeyState(int keyCode);
bool isCapsLockOn = false;
void Start()
{
isCapsLockOn = (((ushort)GetKeyState(0x14)) & 0xffff) != 0;//init stat
}
void Update()
{
if(Input.GetKeyDown(KeyCode.CapsLock))
{
isCapsLockOn = !isCapsLockOn ;
//......
}
}
Personally, that code is out of my area of knowledge so I can’t guarantee anything there.
If that doesn’t work, post the code that you used.
I hope this fixes the problem!
It worked thanks ,and yes i didnt understand this code too lol
Lol. I’m glad that it worked.