// Detect if Caps Lock is enabled during input
const { isCapsLockEnabled, isSupported } = useDetectCapsLock();
Great for password inputs, login forms, or any text input where Caps Lock awareness improves user experience.
Try this:
• Press Caps Lock key to toggle it on/off
• Type letters in the input fields above
• Notice how the password field shows a warning when Caps Lock is enabled
Perfect for login forms and password inputs!
import { useDetectCapsLock } from '@usegrand/react-hokss'; function PasswordInput() { const { isCapsLockEnabled, isSupported } = useDetectCapsLock({ onCapsLockChange: (enabled) => { console.log('Caps Lock is now:', enabled ? 'ON' : 'OFF'); }, global: true }); return ( <div> <input type="password" placeholder="Enter password..." className={isCapsLockEnabled ? 'border-red-500' : ''} /> {isCapsLockEnabled && ( <div className="warning"> ⚠️ Caps Lock is ON </div> )} {!isSupported && ( <div className="info"> Caps Lock detection not supported in this browser </div> )} </div> ); }
Configuration options for Caps Lock detection
Callback function when Caps Lock state changes
Whether to auto-detect on mount (default: true)
Whether to listen globally or on target element (default: true)
Specific element to attach listeners to (if not global)
Object containing Caps Lock state and controls
Boolean indicating if Caps Lock is currently enabled
Boolean indicating if detection is supported
Function to manually check Caps Lock state
Function to reset Caps Lock state
Date of last Caps Lock detection