Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于KeyboardEvent中代码示例问题 #326

Closed
yulilong opened this issue Jun 11, 2018 · 1 comment
Closed

关于KeyboardEvent中代码示例问题 #326

yulilong opened this issue Jun 11, 2018 · 1 comment

Comments

@yulilong
Copy link

https://javascript.ruanyifeng.com/dom/event-type.html#toc19

阮老师你好,在KeyboardEvent.altKey的代码示例中:

function showChar(e){
  console.log("ALT: " + e.altKey);
  console.log("CTRL: " + e.ctrlKey);
  console.log("Meta: " + e.metaKey);
  console.log("Meta: " + e.shiftKey);
}

document.body.addEventListener('click', showChar, false);

监听body元素的鼠标点击事件并不会触发键盘事件, 应该监听keydownkeyup才会触发。

ruanyf added a commit that referenced this issue Jun 12, 2018
@ruanyf
Copy link
Owner

ruanyf commented Jun 12, 2018

谢谢指出,已经更正。

@ruanyf ruanyf closed this as completed Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants