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

添加 keydown 回调 #1397

Closed
zgpnuaa opened this issue May 5, 2023 · 5 comments
Closed

添加 keydown 回调 #1397

zgpnuaa opened this issue May 5, 2023 · 5 comments
Assignees
Milestone

Comments

@zgpnuaa
Copy link

zgpnuaa commented May 5, 2023

想要监听键盘的Enter键是否按下

@Vanessa219
Copy link
Owner

@zgpnuaa
Copy link
Author

zgpnuaa commented May 6, 2023

@Vanessa219 这个只能监听输入内容,怎么像onkeyup一样监听键盘敲入的单个字符呢。
我想监听用户是否按下了回车键,之前用input输入框是这样的:

	document.getElementById('id_chat_message_input').onkeyup = function(e) {
		if (e.keyCode === 13 && e.shiftKey) {  // enter + return(输入+返回)
			// Handled automatically by textarea(由文本区域自动处理)
		}
		else if(e.keyCode === 13 && !e.shiftKey){ // enter + !return (shift键没有按住,发送消息)
			document.getElementById('id_chat_message_submit').click();
		}
	};

现在改成Vditor,想保留这个功能。

@Vanessa219
Copy link
Owner

目前只有 Esc 和 ctrl+enter 的接口

@zgpnuaa
Copy link
Author

zgpnuaa commented May 12, 2023

目前只有 Esc 和 ctrl+enter 的接口

哦哦,后续会有加入监听enter接口的计划吗,我想把Vditor作为消息输入框,然后实现敲enter键发送消息,敲alt+enter实现换行。

@Vanessa219 Vanessa219 changed the title 如何监听键盘onkeyup事件呢? 添加 keydown 回调 May 14, 2023
@Vanessa219 Vanessa219 self-assigned this May 14, 2023
@Vanessa219 Vanessa219 added this to the 3.9 milestone May 14, 2023
Vanessa219 added a commit that referenced this issue May 14, 2023
@Vanessa219
Copy link
Owner

options.keydown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants