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 ...
随机推荐
- spdlog 基本结构分析
spdlog 基本结构分析 代码取自 V1.5.0, 代码堪称美学. spdlog 是一个只有头文件的C++日志库,速度非常快,扩展性很强,更重要的是 社区活跃,文档齐全. 使用 参考官方的 exam ...
- AD19覆铜与边框间距设置方法
转载请注明出处,并附带本文网址https://www.cnblogs.com/brianblog/p/9894867.html, 由于高版本AD不能将机械层直接转变为KEPP OUT LAYER层,所 ...
- Oracle Autonomous Health Framework (AHF) 解读
AHF介绍 Oracle在2019年10月18日发布自治健康框架Autonomous Health Framework (AHF) 19.3,将ORAchk,EXAchk,TFA三种诊断工具合并入AH ...
- Spring Boot 入门(十二):报表导出,对比poi、jxl和esayExcel的效率
本片博客是紧接着Spring Boot 入门(十一):集成 WebSocket, 实时显示系统日志写的 关于poi.jxl和esayExcel的介绍自行百度. jxl最多支持03版excel,所以单个 ...
- 前端.解决form-contral总是换行问题
form-control 总是会换行,后面加单位的时候很难看,如下图. <div class="col-sm-3"> <input id="invest ...
- Vue 编程式的导航
1.应用场景 在同一路由的情况下,不同的参数之间进行切换 注意:别忘记初始化路由页面 2.用法 a.定义方法 b.实现方法 c.初始化路由页面 3.案例 <template> <di ...
- JS 点击验证码刷新
<img src="/get_valid_img" id="valid-img" title="点击再换一张" class=" ...
- Xen+OpenQRM快速部署
一.选择系统平台 a) Ubuntu-11.10-server-amd64 二.Xen安装 a) Xen安装 # apt-get -y install xen-hypervisor-4.1-a ...
- 3分钟接入socket.io使用
WebSocket 简介 传统的客户端和服务器通信协议是HTTP:客户端发起请求,服务端进行响应,服务端从不主动勾搭客户端. 这种模式有个明显软肋,就是同步状态.而实际应用中有大量需要客户端和服务器实 ...
- 对于传统scnece-classfication的分析
BoW模型最初应用于文本处理领域,用来对文档进行分类和识别.BoW 模型因为其简单有效的优点而得到了广泛的应用.其基本原理可以用以下例子来给予描述.给定两句简单的文档: 文档 1:“我喜欢跳舞,小明也 ...