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 ...
随机推荐
- 本地Git绑定Github仓库
前言 Window的小伙伴如果还没在本地配好Git环境可以参考:https://www.cnblogs.com/poloyy/p/12185132.html 创建Github仓库 Github绑定本地 ...
- Frameworks.Entity.Core 7
1描述:实体基类,与业务和架构无关名称:EntityBase属性:public abstract 2描述:/ MongoDB的一些扩展方法名称:MongoExtensions修饰: public st ...
- manually Invoking Model Binding / Model Binding /Pro asp.net mvc 5
限制绑定器 数据源
- robotframework,移动端(小程序)自动化,获取元素属性值的方法
如下图,获取商品价格 属性值显示在content-desc内 传统的get text指定是无法获得到这个元素指定属性的值的 只有通过使用AppiumLibrary.get element attrib ...
- Day10-Python3基础-协程、异步IO、redis缓存、rabbitMQ队列
内容目录: Gevent协程 Select\Poll\Epoll异步IO与事件驱动 Python连接Mysql数据库操作 RabbitMQ队列 Redis\Memcached缓存 Paramiko S ...
- volatile梳理
volatile 可见性也就是说一旦某个线程修改了该被volatile修饰的变量,它会保证修改的值会立即被更新到主存,当有其他线程需要读取时,可以立即获取修改之后的值. 在Java中为了加快程序的运行 ...
- Mesh R-CNN 论文翻译(原理部分)
毕设做Mesh R-CNN的实现,在此翻译一下原论文.原论文https://arxiv.org/pdf/1906.02739.pdf. 摘要 二维感知的快速发展使得系统能够准确地检测真实世界图像中的物 ...
- laravel 学习笔记 — 神奇的服务容器
2015-05-05 14:24 来自于分类 笔记 Laravel PHP开发 竟然有人认为我是抄 Laravel 学院的,心塞.世界观已崩塌. 容器,字面上理解就是装东西的东西.常见的变量.对象属 ...
- 前端性能优化之利用 Chrome Dev Tools 进行页面性能分析
背景 我们经常使用 Chrome Dev Tools 来开发调试,但是很少知道怎么利用它来分析页面性能,这篇文章,我将详细说明怎样利用 Chrome Dev Tools 进行页面性能分析及性能报告数据 ...
- 看片微信号+薇myy9199买片微信号+myy9199绝对靠谱号
最新看片卖片微信号+myy9199,2020最新有效靠谱号,诚信有效,死链包换,2019年11月,我决定学习计算机编程,以java语言为主.我就读于传统工科专业,没怎么接触过计算机相关概念与课程,我知 ...