WHAT'S NEW?
Loading...

javascript key input


Tutorial Details
  • Judul: javascript key input
  • Difficulty: Beginner
  • Platform:javascript
  • Bahasa Scripth: javascript
  • Software : Notepad++
  • Estimated Completion Time: 15 minutes
  • Created:Ricko Nada (Pustaka Flash)





live demo :

Javascript Keyboard Input Example: pencet salasatu keyboard anda dan lihat hasilnya

onkeydown - onkeyup

Keyboard di pencet :
Keyboard Code :

Keyboard Event Status


Scripth yang digunakan :
<script type="text/javascript">
document.onkeydown = function(event) {
var key_press = String.fromCharCode(event.keyCode);
var key_code = event.keyCode;
document.getElementById('kp').innerHTML = key_press;
    document.getElementById('kc').innerHTML = key_code;
var status = document.getElementById('status');
status.innerHTML = "DOWN Event Fired For : "+key_press;
if(key_press == "W"){
alert("Put script to run specific for 'W' key here");
} else if(key_press == "A") {
alert("Put script to run specific for 'A' key here");
} else if(key_press == "S") {
alert("Put script to run specific for 'S' key here");
} else if(key_press == "D") {
alert("Put script to run specific for 'D' key here");
}
}
document.onkeyup = function(event){
    var key_press = String.fromCharCode(event.keyCode);
var status = document.getElementById('status');
status.innerHTML = "UP Event Fired For : "+key_press;
}
</script>
<h2>Javascript Keyboard Input Example: pencet salasatu keyboard anda dan lihat hasilnya</h2>
<h3>onkeydown - onkeyup</h3>
Keyboard di pencet : <span id="kp"></span>
<br />
Keyboard Code : <span id="kc"></span>
<p id="status">Keyboard Event Status</p>

itulah sekiranya tutorial javascript key input,... semoga membantu

0 komentar:

Post a Comment