Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 我应该使用哪个css属性仅在select all命令上禁用文本选择?_Html_Css - Fatal编程技术网

Html 我应该使用哪个css属性仅在select all命令上禁用文本选择?

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;

我应该使用哪个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;
}

我不确定是否有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吗?