input event兼容性
<div class="wrapper">
<p>keypress - event not call on adroid</p>
<input type="text" class="input1">
<span class="code"></span>
</div> <div class="wrapper">
<p>keydown</p>
<input type="text" class="input2">
<span class="code"></span>
</div> <div class="wrapper">
<p>keyup</p>
<input type="text" class="input3">
<span class="code"></span>
</div> <div class="wrapper">
<p>textInput event - no FF or Opera support</p>
<input type="text" id="input4">
<span class="code"></span>
</div> <div class="wrapper">
<p>on input - runs on blur</p>
<input type="text" class="input5">
<span class="code"></span>
</div> <div class="wrapper">
<p>test</p>
<input type="text" id="input6">
<span class="code"></span>
</div> <div class="wrapper">
<p>input number no js</p>
<input type="number" class="">
<span class="code"></span>
</div> <p>
<a href="http://jsfiddle.net/SpYk3/NePCm/">useful detection for events</a>
</p>
$('.input1').keypress(function(e) {
var wrapper = $(this).closest('.wrapper');
var htmlTarget = wrapper.find('.code');
// $(htmlTarget).html(e.which);
// if (e.which == 8) { // 8 is backspace
console.log(e);
var html = "key: " + e.key +", code: " + e.keyCode;
$(htmlTarget).html(html);
// e.preventDefault();
// }
});
$('.input2').keydown(function(e) {
var wrapper = $(this).closest('.wrapper');
var htmlTarget = wrapper.find('.code');
// if (e.which == 8) { // 8 is backspace
console.log(e);
var html = "key: " + e.key +", code: " + e.keyCode;
$(htmlTarget).html(html);
// e.preventDefault();
// }
});
$('.input3').keyup(function(e) {
var wrapper = $(this).closest('.wrapper');
var htmlTarget = wrapper.find('.code');
console.log(e);
var html = "key: " + e.key +", code: " + e.keyCode;
$(htmlTarget).html(html);
});
var input_field = document.getElementById('input4');
input_field.addEventListener('textInput', function(e) {
var wrapper = $(this).closest('.wrapper');
var htmlTarget = wrapper.find('.code');
// e.data will be the 1:1 input you done
var char = e.data; // In our example = "a"
console.log(e);
// If you want the keyCode..
var keyCode = char.charCodeAt(); // a = 97
var html = "key: " + char +", code: " + keyCode;
$(htmlTarget).html(html);
// Stop processing if "a" is pressed
if (keyCode == ) {
e.preventDefault();
return false;
}
return true;
});
$('.input5').on('change', function(e) {
console.log(e);
var wrapper = $(this).closest('.wrapper');
var htmlTarget = wrapper.find('.code');
console.log(e);
var html = "key: " + e.key +", code: " + e.keyCode;
$(htmlTarget).html(html);
});
// $('#input6').on('change', function(e) {
// console.log(e);
// var wrapper = $(this).closest('.wrapper');
// var htmlTarget = wrapper.find('.code');
// console.log(e);
// var html = "key: " + e.key +", code: " + e.keyCode;
// $(htmlTarget).html(html);
// });
var input = document.getElementById('input6');
var oldValue;
var keydownHandler = function(e) {
oldValue = e.target.value;
console.log(oldValue);
}
var inputHandler = function(e) {
var el = e.target,
newValue = el.value;
console.log(newValue);
;
}
input.addEventListener('keydown', keydownHandler);
input.addEventListener('input', inputHandler);
input event兼容性的更多相关文章
- 如何区分/dev/input/event
方法是把每一个/dev/input/event打开.通过ioctl函数来读取设备name,每一个设备name是固定的,可以根据name区分event.我这是查找触摸事件为例:代码如下: static ...
- Input event驱动
Input event驱动 Linux 专门对输入设备. 键盘,鼠标,手柄,触摸屏.按键.封装一个类驱动. 主要统一与应用程序接口.这一类的设备结点都是在/dev/input/eventn( 0< ...
- Exception dispatching input event. use XlistView
今天上午解决Bug,一个上午的时间: log: 11-01 14:49:14.826: E/InputEventReceiver(30810): Exception dispatching input ...
- 如何读取Linux键值,输入子系统,key,dev/input/event,dev/event,C语言键盘【转】
转自:https://blog.csdn.net/lanmanck/article/details/8423669 相信各位使用嵌入式的都希望直接读取键值,特别是芯片厂家已经提供input驱动的情况下 ...
- 利用input event 实时监听input输入的内容
<div id="addNumber"> <p>How many people would you like to invite?</p> &l ...
- js & input event & input change event
js & input event & input change event vue & search & input change <input @click=& ...
- javascript event兼容性随笔
一.前言 function ConvertEvent(e, element) { var event = e || window.event; var resultEvent = { event: e ...
- event兼容性解决
event出现undefind错误 解决方法: $('#normalImgDiv').mousemove(function (e) { var e = window.event || e; var p ...
- 使用JNI封装底层input系统提供的event事件
首先说下思路,本文采用jni技术封装底层触摸事件,封装成MotionEvent类一样,不过没有android系统MotionEvent强大.源码MotionEvent位置:java-->fram ...
随机推荐
- java学生管理系统(增、删、改、查功能)
package mm; import java.util.Scanner;import java.util.ArrayList; class Student1 { private String stu ...
- 前端.解决form-contral总是换行问题
form-control 总是会换行,后面加单位的时候很难看,如下图. <div class="col-sm-3"> <input id="invest ...
- Java入门 - 高级教程 - 04.序列化
原文地址:http://www.work100.net/training/java-serialization.html 更多教程:光束云 - 免费课程 序列化 序号 文内章节 视频 1 概述 2 序 ...
- [新详细]让Keil5续签到2032年的办法,不可商用
# 使用方法和以前的版本一样,MDK 或者C51等均适用,供学习与参考.更多需要到这里购买→ → Keil官网:[http://www.keil.com/](http://www.keil.com/) ...
- Windows10 java环境配置
1.下载 JDK 下载地址:https ://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html 点击下载按钮 ...
- Python3中的super()函数详解
关于Python3中的super()函数 我们都知道,在Python3中子类在继承父类的时候,当子类中的方法与父类中的方法重名时,子类中的方法会覆盖父类中的方法, 那么,如果我们想实现同时调用父类和子 ...
- mysql 基本常用语句
1.展示当前数据库 所有表名(前提必须进入数据库,进入数据库语句:[use 数据库名;])mysql> show create table 表名; 2.看mysql支持哪些存储引擎:mysql& ...
- HashMap实现详解 基于JDK1.8
HashMap实现详解 基于JDK1.8 1.数据结构 散列表:是一种根据关键码值(Key value)而直接进行访问的数据结构.采用链地址法处理冲突. HashMap采用Node<K,V> ...
- OGG主从表结构不同步,出现OGG-01296错误
一.Cause ogg的err日志出现以下报错 2019-09-10 16:36:55 WARNING OGG-01003 Oracle GoldenGate Delivery for Oracle, ...
- Brokers类型配置
模块 配置项 作用域 备注 DynamicConnectionQuota max.connectionsmax.connections.per.ipmax.connections.per.ip.ove ...