📜  javascript caps lock - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:45.698000             🧑  作者: Mango

代码示例1
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 = '';
     }
 });