JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="StreamUrl" />

JavaScript

$("#StreamUrl").keydown(function (e) {
     if (e.keyCode == 32) { 
       $(this).val($(this).val() + "-"); // append '-' to input
       return false; // return false to prevent space from being added
     }
});