Unicode berbeda untuk Listener keypress dan keydown.
Contoh :
Bila tidak muncul Angka Unicode pada KeyPress,
berarti angka unicode tidak dapat digunakan pada fungsi listener keypress.
Keyboard Event : https://www.w3.org/TR/uievents/#events-keyboardevents
Browser Support : https://caniuse.com/#feat=keyboardevent-key
Contoh :
Bila tidak muncul Angka Unicode pada KeyPress,
berarti angka unicode tidak dapat digunakan pada fungsi listener keypress.
Keyboard Event : https://www.w3.org/TR/uievents/#events-keyboardevents
Contoh fungsi listener :
window.addEventListener("keydown", function(event) {
var kcode = event.which || event.keyCode;
if (kcode==13) {
alert('Anda menekan Enter')
}
});
Masukkan Karakter Keyboard :
Data | keydown | keypress | keyup |
---|---|---|---|
keyCode | — | — | — |
charCode | — | — | — |
Target | — | ||
Character | — |
Browser Support : https://caniuse.com/#feat=keyboardevent-key
Related Artikel Code Javascript Keyboard