Coding to integrate my audio button to key on my desktop

i made a audio button and when i click with mouse on that button that audio is playing.
In a similar manner the same audio button has to be played with keys on my key board or desktop keyboard

for examplae,

if press on key “1” my audiobutton " welcome" has to play
if i press on key “2” my audio button “this is party” has to play

i need coding to make a audio player,such that when i press keys on my desktop,for different keys different audio has to be played. if press “a” on my keyboard “xxx.pm3” has to play
if press “r” on my keyboard “yyyy.pm3” has to play

I’m not sure how you’d do this in PHP specifically. I could think of how you might generate some html code with a button on the page and assign a hot-key to it, but that’s not really PHP. Is the button you want to trigger on a web page? Can you show the code you’re using now to link the button to a mouse click?

<!DOCTYPE html>
<html>
<head>
<style type="text/css">
nav#nav1{ margin-top: 24px; }
nav#nav1 > a{ background:#B9E1FF; color:#000; padding:10px; text-decoration:none; border-radius:5px; font-family:"Arial Black", Gadget, sans-serif; }
nav#nav1 > a:hover{ background: #BBEA00; }
nav#nav1 > a:active{ background: #EEFFA8; }
</style>
<script>
var bleep = new Audio();
bleep.src = 'bleep.mp3';
</script>
</head>
<body>
  <nav id="nav1">
    <a href="#" onmousedown="bleep.play()">Home</a>
    <a href="#" onmousedown="bleep.play()">About Us</a>
    <a href="#" onmousedown="bleep.play()">Services</a>
    <a href="#" onmousedown="bleep.play()">Contact</a>
  </nav>
</body>
</html>

this has to played

keypress() function is used ,

I think you’ll get more answers either in the HTML or possibly Javascript areas of the board - I’m still learning PHP, but I don’t think it will help you here.

Topic moved to the JavaScipt category