Hotkey Shortcut

PHOTO EMBED

Fri May 06 2022 07:25:07 GMT+0000 (UTC)

Saved by @myohanhtet #html #javascript

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <form action="/action_page.php">
        <label for="fname">First name:</label>
        <input type="text" id="fname" name="fname"><br><br>
        <label for="lname">Last name:</label>
        <input type="text" id="lname" name="lname"><br><br>
        <input type="submit" value="Submit">
      </form>

<script src="https://unpkg.com/hotkeys-js/dist/hotkeys.min.js"></script>

<script type="text/javascript">
hotkeys('alt+z,alt+x,alt+c,alt+v,alt+b,alt+n,alt+m,alt+1', function (event, handler){
  switch (handler.key) {
    case 'alt+z': document.getElementById("fname").value = "alt+z";
      break;
    case 'alt+x': document.getElementById("fname").value = "alt+x";
      break;
    case 'alt+c': document.getElementById("fname").value = "alt+c";
      break;
    case 'alt+v': document.getElementById("fname").value = "alt+v";
      break;
    case 'alt+b': document.getElementById("fname").value = "alt+b";
      break;
    case 'alt+n': document.getElementById("fname").value = "alt+n";
      break;
    case 'alt+m': document.getElementById("fname").value = "alt+m";
      break;
    case 'alt+1': document.getElementById("fname").value = "alt+1";
      break;
    default: alert(event);
  }
});
</script>
</body>
</html>
content_copyCOPY