文章

javascript检测键盘是否开启大写状态

document.querySelector('input[type=password]').addEventListener('keyup', function (keyboardEvent) {
    const capsLockOn = keyboardEvent.getModifierState('CapsLock');
    if (capsLockOn) {
        // Warn the user that their caps lock is on?
    }
});

来源:https://davidwalsh.name/detect-caps-lock

许可协议:  CC BY 4.0