Play sound on keypress

adaniele

New Member
Messages
6
Reaction score
0
Points
0
Hi

I am trying to make a site that when you press the ENTER key it plays a sound. Here's a script that i've got to detect the enter key. Would someone be able to modify it so it plays a sound instead of a popup message.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--
function detectKey() {
if (event.keyCode==13) {
alert("Enter key has been pressed !");
}
}
function MM_controlSound(x, _sndObj, sndFile) { //v3.0
var i, method = "", sndObj = eval(_sndObj);
if (sndObj != null) {
if (navigator.appName == 'Netscape') method = "play";
else {
if (window.MM_WMP == null) {
window.MM_WMP = false;
for(i in sndObj) if (i == "ActiveMovie") {
window.MM_WMP = true; break;
} }
if (window.MM_WMP) method = "play";
else if (sndObj.FileName) method = "run";
} }
if (method) eval(_sndObj+"."+method+"()");
else window.location = sndFile;
}
//-->
</script>
</head>
<body onkeypress="detectKey()">
</body>
</html>


Any help greatly appreciated
 
Top