Comments (5)
抱歉我无法复现你的问题,我使用如下代码:
$(document).keydown(function(event){
console.log(event.keyCode);
});
无论鼠标焦点在哪都能正常监听所有键盘事件,即使绑定在输入的textarea上,也能正常监听键盘。
浏览器是chrome 87.0.4280.67
from bilibilivtuberlivetool.
from bilibilivtuberlivetool.
b站是用vue劫持事件的,它定义的keydown事件
e.prototype.onKeyDown = function(t) {
13 === t.keyCode && (t.preventDefault(),
this.sendDanmaku(t).then(z.noop).catch(z.noop))
}
在检测到回车的时候会提交弹幕内容并且清空textarea,等他的keydown事件执行完了再执行你的keydown事件,自然就读不到东西了。如果你单纯就是想知道发送了什么,可以去读网站的vue变量,b站在聊天框上绑定了一个vue变量,用.lastMsgContent属性可以看到上一次发送了什么。
from bilibilivtuberlivetool.
from bilibilivtuberlivetool.
客气,我平时没事儿也喜欢捣鼓捣鼓b站相关的js脚本,以后可以多交流。
from bilibilivtuberlivetool.
Related Issues (4)
- 翻译功能不能用啊 HOT 4
- 字幕显示有一定延迟 HOT 4
- 自动捕获同传的弹幕? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bilibilivtuberlivetool.