Html 我应该使用哪个css属性仅在select all命令上禁用文本选择?
我应该使用哪个css类仅在按下Ctrl+A时禁用文本选择,而不是在手动选择文本时禁用它?我尝试过这个,但是这个类不允许我手动选择文本Html 我应该使用哪个css属性仅在select all命令上禁用文本选择?,html,css,Html,Css,我应该使用哪个css类仅在按下Ctrl+A时禁用文本选择,而不是在手动选择文本时禁用它?我尝试过这个,但是这个类不允许我手动选择文本 .title h3 { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
.title h3 {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
我不确定是否有CSS属性。但是,您可以通过向html文件中添加以下javascript片段轻松添加此功能:
<script>
window.addEventListener('keydown', function (e) {
var triggerKey = e.ctrlKey || e.metaKey;
if (e.keyCode === 65 && triggerKey) {
return e.preventDefault(); }
}
);
</script>
如果您不需要担心OSX Mac,只需删除e.metaKey声明,因为它以命令为目标⌘ 键。要禁用CTRL+A吗?