EventModifiers.CapsLock

Description

Is Caps Lock on?

Additional resources: Event.capsLock.

using UnityEngine;
using UnityEngine.UIElements;

[RequireComponent(typeof(UIDocument))] public class Example : MonoBehaviour { // Prints CapsLock on/off depending on the state of the capslock key.

void OnEnable() { var textField = new TextField(); textField.RegisterCallback<KeyDownEvent>(e => { if ((e.modifiers & EventModifiers.CapsLock) != 0) { Debug.Log("CapsLock on."); } else { Debug.Log("CapsLock off."); } }, TrickleDown.TrickleDown); GetComponent<UIDocument>().rootVisualElement.Add(textField); } }

Did you find this page useful? Please give it a rating: