use e.key instead of e.which

This commit is contained in:
Iuri Matias 2019-03-14 13:31:29 -04:00
parent 8b7a374313
commit 785edf4c9d
1 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ class Communication extends Component {
}
handleEnter(e, cb) {
if (e.which === 13) {
if (e.key === 'Enter') {
e.preventDefault();
cb(e);
}
@ -121,9 +121,9 @@ class Communication extends Component {
<FormGroup label="Message">
<Label htmlFor="message">Message</Label>
<Input value={this.state.message}
placeholder="Message"
id="message"
onChange={e => this.handleChange(e, 'message')}
placeholder="Message"
id="message"
onChange={e => this.handleChange(e, 'message')}
onKeyPress={e => this.handleEnter(e, this.sendMessage.bind(this))}/>
</FormGroup>
<Button color="primary" disabled={!this.state.channelIsValid} onClick={(e) => this.sendMessage(e)}>Send Message</Button>