title: React Synthetic Event: How to capture if Enter key is pressed?
body: <p>Why does the event passed below retain 'event.target' value but not 'event.code'?</p>
  
  <pre><code>import React, { useState, useEffect } from 'react';
  import moment from 'moment';
  import { subscribeToTimer } from './api';
  import './App.css';
  
  function App() {
    function getInput(e) {
      console.log(e.target);
      console.log(e.code);
    }
  
    return (
      &lt;&gt;
        &lt;p&gt;Hello World!&lt;/p&gt;
        &lt;input type="text" name="message" className="message" placeholder="Type here..." onKeyUp={(e) =&gt; getInput(e)} /&gt;
      &lt;/&gt;
    );
  }
  
  export default App;
  </code></pre>
  
  <p>How do we capture the 'Enter' key pressed for the input element in React?!</p>