import React, { Component } from 'react'
import { sparqlConnect } from '../sparql/configure-sparql'
import { LOADING, LOADED, FAILED } from 'sparql-connect'
import { browserHistory } from 'react-router'
import { uriToLink } from '../router-mapping'
import { connect } from 'react-redux'

export default class SearchInput extends Component {

  constructor(props) {
    super(props)
    this.handleSubmit = () => {
      browserHistory.push(uriToLink.searchItems(this.refs.search.value.trim(), this.refs.searchForCode.checked))
    }
    this.handleKeyDown = e => {
      if (e.keyCode === 13) this.handleSubmit()
    }
  }

  render() {
    return (
      <span>
        Search everything :
        <input className="search" type="search" placeholder="Enter a keyword"
               ref="search" onKeyDown={this.handleKeyDown} />
        <button onClick={this.handleSubmit}>
          OK
        </button>
        <label><input type="checkbox" ref="searchForCode"/>Search for codes only</label>
      </span>
    )
  }
}

import React, { Component } from 'react'
import { sparqlConnect } from '../sparql/configure-sparql'
import { LOADING, LOADED, FAILED } from 'sparql-connect'
import { browserHistory } from 'react-router'
import { uriToLink } from '../router-mapping'
import { connect } from 'react-redux'

export default class SearchInput extends Component {

  constructor(props) {
    super(props)
    this.handleSubmit = () => {
      browserHistory.push(uriToLink.searchItems(this.refs.search.value.trim(), this.refs.searchForCode.checked))
    }
    this.handleKeyPress = (e) => {
      if (e.key == 'Enter') {
        this.handleSubmit();
      }
    }
  }

  render() {
    return (
      <span>
        Search everything :
        <input className="search" type="search" placeholder="Enter a keyword"
               ref="search" />
        <button onClick={this.handleSubmit}>
          OK
        </button>
        <label><input type="checkbox" ref="searchForCode"/>Search for codes only</label>
      </span>
    )
  }
}

--- 
+++ 
@@ -12,10 +12,8 @@
     this.handleSubmit = () => {
       browserHistory.push(uriToLink.searchItems(this.refs.search.value.trim(), this.refs.searchForCode.checked))
     }
-    this.handleKeyPress = (e) => {
-      if (e.key == 'Enter') {
-        this.handleSubmit();
-      }
+    this.handleKeyDown = e => {
+      if (e.keyCode === 13) this.handleSubmit()
     }
   }
 
@@ -24,7 +22,7 @@
       <span>
         Search everything :
         <input className="search" type="search" placeholder="Enter a keyword"
-               ref="search" />
+               ref="search" onKeyDown={this.handleKeyDown} />
         <button onClick={this.handleSubmit}>
           OK
         </button>
Handle "enter" key in the search box

Fix #35