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. 获取mac地址和IP地址方式

    第一种 public class OperateMAC{ public static string GetMacByWMI() { string MacAddr = null; //Managemen ...

  2. 区块链开发(六)truffle使用入门和testrpc安装

    在上篇博文中我们已经成功安装了truffle及所需相关环境,此篇就简单介绍一些truffle的使用及目录结构等. 简介truffle和testrpc truffle是本地的用来编译.部署智能合约的工具 ...

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

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

  4. 服务端指南 数据存储篇 | 聊聊 Redis 使用场景(转)

    作者:梁桂钊 本文,是升级版,补充部分实战案例.梳理几个场景下利用 Redis 的特性可以大大提高效率. 随着数据量的增长,MySQL 已经满足不了大型互联网类应用的需求.因此,Redis 基于内存存 ...

  5. MBProgressHUD自定义视图大小的修改

    MBProgressHUD 一款简单易用的弹窗,但是在使用中难免使用自定义view即customView,此时会发现HUD的弹窗大小和你image的大小是一样的无论你怎么修改frame也没有用,此时你 ...

  6. 【cocos2d-js官方文档】十一、cc.path

    概述 该单例是为了方便开发者操作文件路径所设计的.定义为cc.path的目的是为了跟nodejs的path保持一致.里面定义的api也基本跟nodejs的path模块一致,但不全有,今后可能还会继续根 ...

  7. 数位dp模版(dp)

    #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> ...

  8. Python web 简单服务器的搭建与运行

    搭建python的CGI环境: 假设在/var/www/cgi-bin下建立一个hello.py的文件 在ubuntu下打开终端 然后用命令 cd /var/www/ 进入后执行命令 : python ...

  9. UVA GCD - Extreme (II)

    discription Given the value of N, you will have to find the value of G. The definition of G is given ...

  10. [xsy2369]取名字

    真是道挺好的题,做一道题学了挺多东西 从操作入手比较困难,所以对硬币进行讨论 考虑一个硬币$(A,B)$,假设$A\lt B$,那么我们可以把操作分成三类 第一类$T_j\lt A$,这种操作是没用的 ...