Postingan lainnya
disable keyboard and enable scanner
saya buat aplikasi parkir berbasis web, tp untuk lebih lengkapnya lagi ,saya ingin disable inputan dari keyboard berupa kode mobil dan hanya bisa untuk inputan berupa scanner ,barcode
0
1 Jawaban:
Anda bisa gunakan JQuery/Javascript untuk men-disable keyboard key (saat keydown/dipencet)
Disable seluruh key halaman tersebut
<script>
document.onkeydown = function (e) {
return false;
}
</script>
Untuk Disable bagian tertentu, bisa gunakan ini:
//semua tag class di disable
<script>
$(".class").keydown(function(event) {
return false;
});
</script>
//semua tag div di disable
<script>
$(".div").keydown(function(event) {
return false;
});
</script>
etc...
Atau hanya mau men-disable key tertentu:
//men-disable enter key (enter key nya 13)
<script type='text/javascript'>
document.onkeydown = function (e) {
var key = e.charCode || e.keyCode;
if (key == 13) {
// enter key do nothing
} else {
e.preventDefault();
}
}
</script>
Source: https://stackoverflow.com/questions/19628081/how-to-disable-full-keyboard-keys-using-javascript-or-jquery https://www.thesoftwareguy.in/disable-keyboard-keys-using-javascript-jquery/
1