导航:首页 > 编程语言 > js虚拟键盘代码

js虚拟键盘代码

发布时间:2023-04-16 11:52:10

『壹』 移动web 怎么捕获虚拟键盘弹出和关闭事件

1、当虚拟键盘弹出的时候,window的resize事件会被触发,问题里的input是使用position:fixed吗,如果是position: fixed,在resize触发时应该会自动调整位置吧。

2、以下js可以实现此效果:

var wHeight = windows.innerHeight; //获取初始可视窗口高度

$(window).resize(function() { //监测窗口大小的变化事件

var hh = windows.innerHeight; //当前可视窗口高度

var viewTop = $(window).scrollTop(); //可视窗口高度顶部距离网页顶部的距离

if(wHeight > hh){ //可以作为虚拟键盘弹出事件碧携掘

$("body,html").animate({scrollTop:viewTop+100}); //调隐衡整可视页面的位置

}else{ //可以作为虚拟键盘关闭事悔核件

$("body,html").animate({scrollTop:viewTop-100});

}

wHeight = hh;

});

『贰』 求js虚拟键盘键盘

按照apollo47的说法
当你取回来后再转换一次就好
return orgStr.replaceAll("<br>","\r\n" );

我们再做开发时候一般会做个转换的工具
或者使用FCKEditor这种开源的组件
一般采用后者来做 网上很多 下个拿来就用

『叁』 用js怎么写一个回车键盘事件

<script type="text/javascript" language=JavaScript charset="UTF-8">

document.onkeydown=function(event){

var e = event || window.event || arguments.callee.caller.arguments[0];

if(e && e.keyCode==27){ // 按 Esc

//要做的事情

}

if(e && e.keyCode==113){ // 按 F2

//要做的事情

}

if(e && e.keyCode==13){ // enter 键

//要做的事情

}

};

</script>

(3)js虚拟键盘代码扩展阅读:

Js键盘事件

keydown:按键按下

keyup:按键抬起

keypress:按键按下抬起

<body>

<input id="name" type="text" onkeydown="myKeyDown(this.id)" onkeyup="myKeyUp(this.id)">

</body>

<script>

/*输出输入的字符*/

function myKeyDown(id) {

console.log(document.getElementById(id).value);

}

/*按键结束,字体转换为大写*/

function myKeyUp(id) {

var text = document.getElementById(id).value;

document.getElementById(id).value = text.toUpperCase();

}

</script>

常用的键盘事件对应的键码:

keyCode 8 = BackSpace BackSpace

keyCode 9 = Tab Tab

keyCode 12 = Clear

keyCode 13 = Enter

keyCode 16 = Shift_L

keyCode 17 = Control_L

keyCode 18 = Alt_L

keyCode 19 = Pause

keyCode 20 = Caps_Lock

keyCode 27 = Escape Escape

『肆』 js自动弹出手机键盘,而不是要点击文本框再弹出虚拟键盘的,如何实现

autofocus 属性 : 文裤磨弊本输入字段被设置为当页面加胡族游歼载时获得焦点

<input type="text" autofocus="autofocus"> 试试这个

『伍』 想请教一下各位高手虚拟键盘应该如何写。

使用keybd_event函数:
VOID keybd_event(
BYTE bVk, // virtual-key code
BYTE bScan, // hardware scan code
DWORD dwFlags, // flags specifying various function options
DWORD dwExtraInfo // additional data associated with keystroke
);
你是做了很多按钮,然后响应按钮按下的消息吗?如果是这样的话,就在按钮按下的消息函数里添加如下的代码就行了(反正就是添加到你姿袭需要模拟按键的那个地方):
keybd_event(VK_H, 0, 0, 0); // 模卜册消拟按下H键
要模拟其他键只需要把第一个参数改成相应的虚键值就行了,所有的虚键值表示如下:
KEY_EVENT_BASE
The base identifier for all UIKeyEvent events.
KEY_PRESSED
The key pressed event type.
KEY_RELEASED
The key released event type.
KEY_TYPED
The key typed event type, which is generated by a combination of a key press followed by a key release.
VK_0
VK_0 through VK_9 are the same as ASCII "0" through "9" (0x30 - 0x39).
VK_1
A virtual key code for the ASCII "1" key.
VK_2
A virtual key code for the ASCII "型知2" key.
VK_3
A virtual key code for the ASCII "3" key.
VK_4
A virtual key code for the ASCII "4" key.
VK_5
A virtual key code for the ASCII "5" key.
VK_6
A virtual key code for the ASCII "6" key.
VK_7
A virtual key code for the ASCII "7" key.
VK_8
A virtual key code for the ASCII "8" key.
VK_9
A virtual key code for the ASCII "9" key.
VK_A
VK_A through VK_Z are the same as ASCII "A" through "Z" (0x41 - 0x5A).
VK_ACCEPT
For Asian keyboards.
VK_ADD
A virtual key code for the numeric keypad PLUS SIGN (+) key.
VK_ALT
A virtual key code for the ALT key.
VK_B
A virtual key code for the ASCII "B" key.
VK_BACK_QUOTE
A virtual key code for the apostrophe (`) key.
VK_BACK_SLASH
A virtual key code for the BACKSLASH (\) key.
VK_BACK_SPACE
A virtual key code for the BACKSPACE key.
VK_C
A virtual key code for the ASCII "C" key.
VK_CANCEL
A virtual key code for the CANCEL key.
VK_CAPS_LOCK
A virtual key code for the CAPS LOCK key.
VK_CLEAR
A virtual key code for the CLEAR key.
VK_CLOSE_BRACKET
A virtual key code for the CLOSE BRACKET (]) key.
VK_COMMA
A virtual key code for the COMMA (,) key.
VK_CONTROL
A virtual key code for the CTRL key.
VK_CONVERT
For Asian keyboards.
VK_D
A virtual key code for the ASCII "D" key.
VK_DECIMAL
A virtual key code for the numeric keypad DECIMAL POINT (.) key.
VK_DELETE
A virtual key code for the DELETE key.
VK_DIVIDE
A virtual key code for the numeric keypad DIVISION (/) key.
VK_DOWN
A virtual key code for the DOWN ARROW key.
VK_E
A virtual key code for the ASCII "E" key.
VK_END
A virtual key code for the END key.
VK_ENTER
A virtual key code for the ENTER key.
VK_EQUALS
A virtual key code for the EQUAL SIGN (=) key.
VK_ESCAPE
A virtual key code for the ESC key.
VK_F
A virtual key code for the ASCII "F" key.
VK_F1
A virtual key code for the F1 key.
VK_F10
A virtual key code for the F10 key.
VK_F11
A virtual key code for the F11 key.
VK_F12
A virtual key code for the F12 key.
VK_F2
A virtual key code for the F2 key.
VK_F3
A virtual key code for the F3 key.
VK_F4
A virtual key code for the F4 key.
VK_F5
A virtual key code for the F5 key.
VK_F6
A virtual key code for the F6 key.
VK_F7
A virtual key code for the F7 key.
VK_F8
A virtual key code for the F8 key.
VK_F9
A virtual key code for the F9 key.
VK_FINAL
For Asian keyboards.
VK_G
A virtual key code for the ASCII "G" key.
VK_H
A virtual key code for the ASCII "H" key.
VK_HELP
A virtual key code for the HELP key.
VK_HOME
A virtual key code for the HOME key.
VK_I
A virtual key code for the ASCII "I" key.
VK_INSERT
A virtual key code for the INSERT key.
VK_J
A virtual key code for the ASCII "J" key.
VK_K
A virtual key code for the ASCII "K" key.
VK_KANA
For Asian keyboards.
VK_KANJI
For Asian keyboards.
VK_L
A virtual key code for the ASCII "L" key.
VK_LEFT
A virtual key code for the LEFT ARROW key.
VK_M
A virtual key code for the ASCII "M" key.
VK_META
A virtual key code for the Application key (found on Microsoft® Windows® 95 keyboards).
VK_MODECHANGE
For Asian keyboards.
VK_MULTIPLY
A virtual key code for the numeric keypad MULTIPLICATION (*) key.
VK_N
A virtual key code for the ASCII "N" key.
VK_NONCONVERT
For Asian keyboards.
VK_NUM_LOCK
A virtual key code for the NUM LOCK key.
VK_NUMPAD0
A virtual key code for the numeric keypad "0" key.
VK_NUMPAD1
A virtual key code for the numeric keypad "1" key.
VK_NUMPAD2
A virtual key code for the numeric keypad "2" key.
VK_NUMPAD3
A virtual key code for the numeric keypad "3" key.
VK_NUMPAD4
A virtual key code for the numeric keypad "4" key.
VK_NUMPAD5
A virtual key code for the numeric keypad "5" key.
VK_NUMPAD6
A virtual key code for the numeric keypad "6" key.
VK_NUMPAD7
A virtual key code for the numeric keypad "7" key.
VK_NUMPAD8
A virtual key code for the numeric keypad "8" key.
VK_NUMPAD9
A virtual key code for the numeric keypad "9" key.
VK_O
A virtual key code for the ASCII "O" key.
VK_OPEN_BRACKET
A virtual key code for the OPEN BRACKET ([) key.
VK_P
A virtual key code for the ASCII "P" key.
VK_PAGE_DOWN
A virtual key code for the PAGE DOWN key.
VK_PAGE_UP
A virtual key code for the PAGE UP key.
VK_PAUSE
A virtual key code for the PAUSE (BREAK) key.
VK_PERIOD
A virtual key code for the PERIOD (.) key.
VK_PRINTSCREEN
A virtual key code for the PRINT SCREEN key.
VK_Q
A virtual key code for the ASCII "Q" key.
VK_QUOTE
A virtual key code for the QUOTATION MARK key.
VK_R
A virtual key code for the ASCII "R" key.
VK_RIGHT
A virtual key code for the RIGHT ARROW key.
VK_S
A virtual key code for the ASCII "S" key.
VK_SCROLL_LOCK
A virtual key code for the SCROLL LOCK key.
VK_SEMICOLON
A virtual key code for the SEMICOLON (;) key.
VK_SEPARATER
VK_SHIFT
A virtual key code for the SHIFT key.
VK_SLASH
A virtual key code for the forward slash (/) key.
VK_SPACE
A virtual key code for the SPACEBAR key.
VK_SUBTRACT
A virtual key code for the numeric keypad MINUS SIGN (-) key.
VK_T
A virtual key code for the ASCII "T" key.
VK_TAB
A virtual key code for the TAB key.
VK_U
A virtual key code for the ASCII "U" key.
VK_UNDEFINED
KEY_TYPED events do not have a defined key code.
VK_UP
A virtual key code for the UP ARROW key.
VK_V
A virtual key code for the ASCII "V" key.
VK_W
A virtual key code for the ASCII "W" key.
VK_X
A virtual key code for the ASCII "X" key.
VK_Y
A virtual key code for the ASCII "Y" key.
VK_Z
A virtual key code for the ASCII "Z" key.

『陆』 js怎么听移动端键盘展开事件

方法一实现代码:

var winHeight = $(window).height();

$(window).resize(function(){

var thisHeight=$(this).height();

if(winHeight - thisHeight >50){

//窗口发生改变(大),故此时键盘弹出

//当软键盘弹出,在这里面操作

}else{

//窗口发生改变(小),故此时键盘收起

//当软键盘收起,在此处操作

}

});

方法二:监控键盘。

监控的方式其实筛选下来也不过两种:

① 时钟setInterval不停监控

系统级别的监控,比如键盘出现时候通知window一个事件,但是很遗憾现在还没有这个事件,但是这个事件等于

input类元素获取焦点 == 弹出虚拟键盘

input类元素失去焦点 == 收起虚拟键盘

基于系统监控这点,我们还可以监控resize事件或者scroll事件,但是经过我的测试。

setInterval表现比较好.于是,我们简单写一段代码,可靠是否满足需求:

window.alert = function (msg) {

$('body').append('<div>' + msg + '</div>')

};

function fixedWatch(el) {

if(document.activeElement.nodeName == 'INPUT'){

el.css('position', 'static');

} else {

el.css('position', 'fixed');

}

}

setInterval(function () {

fixedWatch($('#headerview header'));

}, 500);

『柒』 如何用js输出键盘按键

<input type="button" name="btn" value="点击101"
onclick=" cal(prompt('请输入第一个键盘按键字母:'),prompt('请输入第二个键盘按键字母:')) " />
<script type="text/javascript">
function cal(num01,num02){
/*var num11 = parseInt(num01);
var num22 = parseInt(num02);*/
alert(num01);
alert(num02);
}
</script>

『捌』 js怎么控制虚拟键盘弹出和收起

js 移动端关于页面布局,如果底部有position:fixed的盒子,又有input,当软键盘弹出收起都会影响页面布局。这时候可以监听resize事件,代码如下,而ios没有相关事件。
var winHeight = $(window).height(); //获取当前页面高度$(window).resize(function(){ var thisHeight=$(this).height(); if(winHeight - thisHeight >50){ //当软键盘弹出,在这里面操作 }else{ //当软键盘收起,在此处操作 }
});

/**
* 解决ios键盘弹出遮挡input
*/
function iosInput() {
if(isIos()){
$('.chart-footer').css('position','absolute');
//解决第三方软键盘唤起时底部input输入框被遮挡问题
var bfscrolltop = document.body.scrollTop;//获取软键盘唤起前浏览器滚动部分的高度
$(".chart-input").focus(function(){//在这里‘input.inputframe’是我的底部输入栏的输入框,当它获取焦点时触发事件
interval = setInterval(function(){//设置一个计时器,时间设置与软键盘弹出所需时间相近
document.body.scrollTop = document.body.scrollHeight;//获取焦点后将浏览器内所有内容高度赋给浏览器滚动部分高度
},100)
}).blur(function(){//设定输入框失去焦点时的事件
clearInterval(interval);//清除计时器
document.body.scrollTop = bfscrolltop;
//将软键盘唤起前的浏览器滚动部分高度重新赋给改变后的高度
});
}
}
iosInput();

『玖』 虚拟键盘按键的代码是什么

set WshShell = WScript.CreateObject("WScript.Shell") WshShell.SendKeys ("哪祥枝李敏宴团^a") 其中^ 是Ctrl键s

『拾』 js手机端如何点击某个按钮自动弹出虚拟键盘,急~~~~~~~!!!

JS做事可以的啊,HTML5其实就是大量的JS接口,不过好像挺麻烦啊

阅读全文

与js虚拟键盘代码相关的资料

热点内容
616可用qq音乐 浏览:841
jscss换肤 浏览:194
手机qq今日访客怎么算 浏览:923
word表格中如何插入表格 浏览:230
u盘自动运行文件 浏览:228
没有配置文件怎么删除 浏览:275
office2010怎么设置密码 浏览:500
编程软件推荐哪个好 浏览:691
索佳电视系统升级 浏览:296
怎么覆盖文件表格视频 浏览:884
货车拉韵达快递用什么app 浏览:949
安庆5g网络什么时候上市 浏览:936
文件输出流的相对路径 浏览:288
苹果5c升级时打不开机怎么回事 浏览:52
台湾虾皮网站怎么发货 浏览:303
vs2008格式化代码快捷键 浏览:579
潮流声音聊天交友app有哪些 浏览:406
txd文件怎么打开 浏览:693
高仿微信聊天界面文件语音 浏览:398
网络电视如何搜到想要看的韩剧 浏览:425

友情链接