You need to register a callback function, which will be invoked whenever a key in keyboard is pressed and your logic has to be in that function (or some other function and invoked from this callback function), like this
document.getElementById("cmdLine").addEventListener('keydown', function (event) {
if (event.keyCode === 13) {
var cmdValue = document.getElementById('cmdLine').value;
switch (cmdValue) {
case "jump":
console.log("FTL Jump to new system: SUCCESS");
break;
case "refuel":
case "repair":
console.log("Refuel: SUCCESS");
break;
default:
console.log("Command not recognized");
}
}
});