JSFiddle - React, Tailwind, and code Playground

by dexterity

HTML

Individual detect<br>
<input id="myinput" placeholder="Click command key on your mac"><br>
<div class="output" id="output"></div><br><br>
right or left detect<br>
<input id="myinput2" placeholder="Click command key on your mac"><br><br>
<div class="output" id="output2"></div>
<br>
Like @officialmcoves on social media for more free codes

CSS

input {
  width: 200px;
}
div {
  height: 20px;
}

JavaScript

$(document).on('keydown', '#myinput', function() {
  if (event.keyCode == '91') {
    $("#output").empty().append("left command clicked");
  }

  if (event.keyCode == '93') {
    $("#output").empty().append("right command clicked");
  }
});

$(document).on('keydown', '#myinput2', function() {
  if (event.keyCode == '91' || event.keyCode == '93') {
    $("#output2").empty().append("right or left command clicked");
  }
});

$("input").on('blur', function() {
  $(".output").empty();
});