代码驿站移动版
频道导航
HTML/Xhtml
CSS
JavaScript
HTML5
PHP教程
ASP.NET
正则表达式
AJAX
ThinkPHP
Yii
MySQL
MariaDB
Oracle
MongoDB
Redis
DedeCMS
PHPCMS
帝国CMS
WordPress
Discuz
其它CMS
Zend Studio
Sublime
Notepad
Dreamweaver
Windows
Linux
Nginx
Apache
IIS
CentOS
Ubuntu
Debian
网站优化
工具资源
PHP源码
ASP.NET源码
其它源码
图标素材
按钮素材
字体素材
DedeCMS模板
帝国CMS模板
PHPCMS模板
WordPress模板
Discuz!模板
单页模板
开发软件下载
服务器软件下载
广告投放
联系我们
版权申明
软件编程
网页前端
移动开发
数据库
服务器
脚本语言
PHP代码
JAVA代码
Python代码
Android代码
当前位置:
主页
>
网页前端
>
JavaScript代码
>
按键测试,支持像 Ctrl+Alt+Shift+T 的组合键
时间:2021-09-26 10:15:48 | 栏目:
JavaScript代码
| 点击:次
<html> <head> </head> <body onkeyup="window.alert(showKeyName(event))"> 按键测试,支持像 Ctrl+Alt+Shift+T 的组合键(注:非浏览器热键) <script type="text/javascript"> function showKeyName(e) { var keyName; switch(e.keyCode) { case 8:keyName = "[退格]";break; case 9:keyName = "[Tab]";break; case 13:keyName = "[Enter]";break; case 16:keyName = "[Shift]";break; case 17:keyName = "[Ctrl]";break; case 18:keyName = "[Alt]";break; case 19:keyName = "[PauseBreak]";break; case 20:keyName = "[Caps Lock]";break; case 27:keyName = "[Esc]";break; case 32:keyName = "[空格]";break; case 33:keyName = "[PageUp]";break; case 34:keyName = "[PageDown]";break; case 35:keyName = "[End]";break; case 36:keyName = "[Home]";break; case 37:keyName = "[方向键左]";break; case 38:keyName = "[方向键上]";break; case 39:keyName = "[方向键右]";break; case 40:keyName = "[方向键下]";break; case 45:keyName = "[Insert]";break; case 46:keyName = "[Delete]";break; case 91:keyName = "[左Win]";break; case 92:keyName = "[右Win]";break; case 93:keyName = "[快捷菜单键]";break; case 95:keyName = "[Sleep]";break; case 96:keyName = "[小键盘区0]";break; case 97:keyName = "[小键盘区1]";break; case 98:keyName = "[小键盘区2]";break; case 99:keyName = "[小键盘区3]";break; case 100:keyName = "[小键盘区4]";break; case 101:keyName = "[小键盘区5]";break; case 102:keyName = "[小键盘区6]";break; case 103:keyName = "[小键盘区7]";break; case 104:keyName = "[小键盘区8]";break; case 105:keyName = "[小键盘区9]";break; case 106:keyName = "[*]";break; case 107:keyName = "[+]";break; case 109:keyName = "[-]";break; case 110:keyName = "[.]";break; case 111:keyName = "[/]";break; case 112:keyName = "[F1]";break; case 113:keyName = "[F2]";break; case 114:keyName = "[F3]";break; case 115:keyName = "[F4]";break; case 116:keyName = "[F5]";break; case 117:keyName = "[F6]";break; case 118:keyName = "[F7]";break; case 119:keyName = "[F8]";break; case 120:keyName = "[F9]";break; case 121:keyName = "[F10]";break; case 122:keyName = "[F11]";break; case 123:keyName = "[F12]";break; case 144:keyName = "[NumLock]";break; case 145:keyName = "[ScrollLock]";break; case 186:keyName = "[;]";break; case 187:keyName = "[=]";break; case 188:keyName = "[,]";break; case 189:keyName = "[-]";break; case 190:keyName = "[.]";break; case 191:keyName = "[/]";break; case 192:keyName = "[`]";break; case 219:keyName = "[[]";break; case 220:keyName = "[\\]";break; case 221:keyName = "[]]";break; case 222:keyName = "[']";break; //case 255:keyName = "[Power]";break; //奇怪,怎么[Power]键和[Wake]键键值是一样的? case 255:keyName = "[Wake]";break; default:keyName = "[" + String.fromCharCode(e.keyCode) + "]";break; } if((e.shiftKey)&&(e.keyCode!=16)){keyName = "[Shift] + " + keyName;} if((e.altKey)&&(e.keyCode!=18)){keyName = "[Alt] + " + keyName;} if((e.ctrlKey)&&(e.keyCode!=17)){keyName = "[Ctrl] + " + keyName;} return keyName; } </script> </body> </html>
[Ctrl+A 全选 注:
引入外部Js需再刷新一下页面才能执行
]
您可能感兴趣的文章:
JavaScript常见事件处理程序实例总结
Javascript的匿名函数小结
url传递的参数值中包含&时,url自动截断问题的解决方法
Javascript别踩白块儿(钢琴块儿)小游戏实现代码
兼容浏览器的js事件绑定函数(详解)
相关文章
10-19
javascript上下左右定时滚动插件
11-23
Webpack中loader打包各种文件的方法实例
11-27
Javascript实例教程(19) 使用HoTMetal(2)
10-05
javascript判断图片是否加载完成的方法推荐
11-22
在javascript中执行任意html代码的方法示例解读
JQuery
VUE
AngularJS
MSSql
MySQL
MongoDB
Redis
Linux
Tomcat
Nginx
网站首页
广告投放
联系我们
版权申明
联系站长