JavaScript DHTML/Event/Alt Key

Материал из Web эксперт
Перейти к: навигация, поиск

"altKey" Example

   <source lang="html4strict">
   

<html> <head> <script language="JavaScript">

   function function1() {
       var m = event.altKey;
       if (m == false) {
           alert("The Alt Key is not pressed");
           document.all.myButton.value = "Click here while pressing the Alt key";
       } else if(m == true) {
           alert("The Alt Key is pressed");
           document.all.myButton.value = "Click here"; 
       }
   }

</script> </head> <body> <input id="myButton" type="button" value="Click here" onClick="function1();"> </body> </html>


     </source>
   
  


"altLeft" Example

   <source lang="html4strict">
   

<html> <head> <script language="JavaScript">

   function function1() {
       var m = event.altLeft;
       if (m == false) {
           alert("The Left Alt Key is not pressed");
           document.all.myButton.value = "Click here while pressing the Alt key";
       } else if(m == true) {
           alert("The Alt Key is pressed");
           document.all.myButton.value = "Click here"; 
       }
   }

</script> </head> <body> <input id="myButton" type="button" value="Click here" onClick="function1();"> </body> </html>


     </source>