Skip to content

Typewriter sound on keypress for Javascript

Notifications You must be signed in to change notification settings

niklasHagner/keypress

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Javascript Typewriter

  • Plays random keyboard click sounds.
  • Uses vanilla JS and mp3 files

Files

  • keypress.js - the library itself
  • /sounds - contains 9 mp3 files (key0.mp3, key1.mp3 ...)
  • demo.html - oldschool terminal demo
  • demo.js - shows some examples
  • css - styling for the terminal demo

Getting started

  • Include keypress.js and the /sounds folder
  • Check out demo.js for sample code
//create one KeyPressSoundController (the library wrapper)
var soundPlayer = KeyPressSoundController();
//start playing sounds on the keypress event
document.getElementById('keypressArea').addEventListener("keypress",
  function() {
    soundPlayer.PlayRandomSound();
  }
);

Credits

Can it play different sounds for different keys?

I've included a list of JS keycodes so you can modify the script to your liking

About

Typewriter sound on keypress for Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CSS 47.7%
  • JavaScript 38.3%
  • HTML 14.0%