javascript - How to find Virtual key Code of keys i.e 0x41
问题描述
Is there a way to find the Virtual key Value of a key with javascript that will return eg-"0x41
" instead of "65
" ("A
") for characters? I have tried .keyup(e)
but it gives me "65
" instead of "0x41
". Would anyone know what could be done?
解决方案
Javascript has a built in library for this conversion of hex/dec; check it out.
const dectohex = (decimalnum) => decimalnum.toString(16);
const hextodec = (hexnum) => parseInt(hexnum, 16);
console.log(dectohex(65));
推荐阅读
- python - 为什么在使用 psycopg2 时 INSERT INTO [local table] SELECT ... FROM [foreign data wrapper table] 会挂起?
- reactjs - 如何在 React 中的字符串变量中进行字符串插值?
- c - 使用 Tcl C APi 实现读写器问题
- google-apps-script - 如何继续使用谷歌脚本?
- sql - EF 核心代码首先迁移自动为表添加 db_owner 前缀
- android - Android:在 Android 应用中自动隐藏音量栏
- javascript - 从嵌套的对象数组中删除一个对象
- ssl - Kafka,为什么我在使用kafka-console-producer(或Kafkcat)进行测试时需要传递证书链而不仅仅是根ca
- ios - 无效的权利 Xcode
- android - 在 getview 中实现 SharedPreference