How to prevent the html details element from toggling when the summary has an embedded text input and user presses space bar

You can catch the event on summary object and then preventDefault() will not toggle details element state but also will not block space addition.

window.onload = function() {
  var summary = document.getElementById("x");
  var fn = function(e) {      
    if(e.keyCode == 32){
      e.preventDefault();
    }
  };
  summary.onkeyup = fn;
};
<details open>
  <summary id="x"><input  type="text" /></summary>
  Some content
</details>

Pay attention i moved id="x" to summary instead of input