在文本区域内:如果用户在空行上按 Enter 键,则捕获
我知道这是一个奇怪的问题,但是:在文本区域内,我如何知道用户是否在 keydown 事件上按 Enter (e.keycode==13) 在空行?
每次用户按下 Enter 时,我都必须触发特定的同步函数,除非用户只是为了好玩而添加新行(在这些情况下调用同步函数,将是对资源的严重浪费)。
I know this is kind of an odd question, but: Inside a textarea, how can I know if the user is pressing enter (e.keycode==13) on an empty line on the keydown event?
I have to trigger a specific sync function everytime the user presses enter except if the user is just adding new lines for fun (calling the sync function in those cases, would be a terrible waste of resources).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到解决办法了!
Found a solution!
嗯,这取决于他们最初是如何到达那里的。如果用户在整行上按 Enter 键,同步函数是否会被调用?如果是这样,那么他们如何才能到达空行呢?
Well, it depends on how they got there in the first place. If the user presses enter on a full line does the sync function get called? If so, then how do they ever get to an empty line?