e.which is not an event, which is a property of the event object, which most people label as e in their event handlers. It contains the key code of the key which was pressed to trigger the event (eg: keydown, keyup).

document.onkeypress = function(myEvent) { // doesn't have to be "e"
console.log(myEvent.which);
};

With that code, the console will print out the code of any key you press on the keyboard.

随机推荐

  1. 关于hrtimer_forward小段代码的分析【转】

    转自:http://blog.csdn.net/wowuyinglingluan/article/details/45720151 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?) ...

  2. IC卡的传输协议(2)-块传输协议T=1【转】

    转自:http://bbs.ednchina.com/BLOG_ARTICLE_172024.HTM 2.4 块传输协议T=1 T=1协议中,在TAL和IC卡之间传送的命令.R-APDU和传输控制信息 ...

  3. 复选框回显、全选、非全选、cookie处理数据、json数组对象转换处理学习笔记参考的页面

    <%@include file="/common/head.jsp"%> <%@ page contentType="text/html; charse ...

  4. 区块链开发(四)Nodejs下载&安装

    以太坊框架truffle的安装需要依赖nodejs中的npm命令,本篇博客我们就简单介绍一下node的安装过程.操作系统基于ubuntu 16.04版本. 下载地址 nodejs官网:http://w ...

  5. KVM(八)使用 libvirt 迁移 QEMU/KVM 虚机和 Nova 虚机

    1. QEMU/KVM 迁移的概念 迁移(migration)包括系统整体的迁移和某个工作负载的迁移.系统整理迁移,是将系统上所有软件包括操作系统完全复制到另一个物理机硬件机器上.虚拟化环境中的迁移, ...

  6. iptables 执行清除命令 iptables -F 要非常小心

    使用 /sbin/iptables -F 要小心,搞不好,你就马上同服务器断开连接了 以下是来自 http://wiki.ubuntu.org.cn/IptablesHowTo 上的说明 可以通过/s ...

  7. java callable future futuretask

    Runnbale封装一个异步运行的任务,可以把它想象成一个没有任何参数和返回值的异步方法.Callable和Runnable相似,但是它有返回值.Callable接口是参数化的类型,只有一个方法cal ...

  8. 利用PyPDF2删除PDF文件首页

    前话:有个朋友让我给他编辑他们公司的PDF文件,签名的日期时间不对,需要进(nong)行(xu)优(zuo)化(jia).而我手上只有两个管理pdf的软件,一个福晰阅读器,还有一个福晰编辑器.但是阅读 ...

  9. Codeforces Round 251 (Div. 2)

    layout: post title: Codeforces Round 251 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  10. Codeforces #432 Div2 D

    #432 Div2 D 题意 给出一些数字,如果这些数字的的 \(gcd\) 不为1则称这些数字 \(good\). 可以有两种操作: 花费 x 删掉一个数 花费 y 将一个数加 1 问使这些数 \( ...