diff --git a/mcserver-manager/src/main/resources/components.js b/mcserver-manager/src/main/resources/components.js index b4d5570..e838fb4 100644 --- a/mcserver-manager/src/main/resources/components.js +++ b/mcserver-manager/src/main/resources/components.js @@ -93,6 +93,13 @@ var WebConsole = React.createClass({ focusInput: function() { this.refs.input.focus(); }, + handleKeyInput: function(event) { + if (event.key === 'Enter') { + console.debug("send command '" + this.refs.input.value + "'"); + this.ws.send(':'+this.refs.input.value); + this.refs.input.value = ''; + } + }, /*--------------------*/ getInitialState: function(){return{ lines: [] @@ -107,7 +114,7 @@ var WebConsole = React.createClass({ return ce('p', {dangerouslySetInnerHTML: {__html: ansi_up.ansi_to_html(line)}}); }) ), - ce('input', {ref: 'input'}) + ce('input', {ref: 'input', 'onKeyPress': this.handleKeyInput}) ) ) },