📜  js contenteditable 按钮空格键 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:51.835000             🧑  作者: Mango

代码示例1
const button = document.querySelector('button[contenteditable]')

button.addEventListener('keydown', function (event) {
  if (event.code !== 'Space') {
    return
  }
  event.preventDefault()
  document.execCommand("insertText", false, ' ')
})