📅  最后修改于: 2022-03-11 15:02:45.698000             🧑  作者: Mango
const password = document.querySelector('#password');
const message = document.querySelector('.message');
password.addEventListener('keyup', function (e) {
if (e.getModifierState('CapsLock')) {
message.textContent = 'Caps lock is on';
} else {
message.textContent = '';
}
});