hello everyone!
I’m looking for a way to get the current capslock state, but didn’t have found anything that works
any idea??
I don’t think thats possible in Unity I’m afraid, unless you write your own native plugin to get it.
What you can do is handle key-down events with KeyCode.CapsLock, but this will not pick up the actual state of the capslock if it changes outside your game.
class CapsLock : MonoBehaviour
{
private bool m_CapsLock = false;
void Update()
{
if (Input.GetKeyDown(KeyCode.CapsLock)
{
m_CapsLock = !m_CapsLock;
}
}
}
no, this is a “fake way” and didn’t work if you are developing a password system for example, what I neet is a way to get the REAL caps lock status, propably I’ll need to develop my native plugin for that :-/
There is actually this that you might be able to use Control.IsKeyLocked(Keys) Method (System.Windows.Forms) | Microsoft Learn
yes, I’m was reading this link right now xD I made my native plugin and it worked <3
BUT! I’ve contacted the guys from Unity too asking if there something for this inside the engine, if have I’ll post here, if not, I’ll create a nice plugin with some stuff and publish on asset store
any news on this?
hey! yes! I had a hardware fail and lost it xD
I’ll try to recode it, and as it is a little more hard and may need some different code on each platform (and I didn’t have time for it right now), I’ll open the source on github…