JS Comenteditable Button Spacebar

const button = document.querySelector('button[contenteditable]')

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