Js enables the keyboard to press the left and right keys to select text and display it in the text box
This example describes how to enable Javascript to enable the keyboard to select text and display it in the text box. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Javascript captures keys pressed on the keyboard.
A small demo uses js to capture the key on the keyboard and then display the corresponding code value.
The above is all the content of this article. I hope you will like it.
Keyboard keys
$ (document). Ready (function () {
$ (document). Bind ("ContextMenu", function (e) {
return false;
});
});
A little different.
$ (' body '). Bind ("Selectstart", function () {return false;});
You can use it if you want to ban copying in Firfox.
Body
{
-moz-user-focus:ignore;
-moz-user-select:none;
}
To define the
The following are some of the
You can use the keyboard up and down keys to select code, which is convenient for you to operate on the two sections using the keyboard up and down keys for selection:
Section 1
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Section 2
[Ctrl + A select all No
Notebook computers are now the mainstream of the PC market, and most users tend to use laptops. But some users say they occasionally get a bit of a keyboard disorder when they use a WINDOWS8 notebook computer.
As shown in the illustration above, this may be the result of a redefinition of the keyboard keys.
Solving method
Modify the Registration For
The keyboard is used all the time, and suddenly the next few keys cannot be pressed.
The possibility of damage or contamination at the same time is very small, possibly due to the circuit board partial line rupture caused. The keyboard back cover open, with universal table detection, found that the printed circuit board has a very fine fracture, resulting
Private SubForm_keypress (Sender as ObjectE asKeyPressEventArgs)Handles Me. KeyPressIfE.keychar = ChrW ( -) Then DimMessge as NewMSG Messge.head.Text="Coming out of the system"MESSGE.MSGP.Text="Press ENTER to exit the system, ESC to return ..."Messge. Show ()End If IfE.keychar = CHR ( the) Then DimMessge as NewMSG Messge.head.Text="F4"MESSGE.MSGP.Text="You pressed the F4."Messge. Show ()End If IfE.keychar = CHR ( the) Then DimMessge as NewMSG Messg
Determine whether you want to disable the global control or specify the control. If it is global, you only need to listen to the window. keyDownfunction (event ){.....} the same is true. If you are interested, you can check whether you want to disable global controls or specified controls. For example, if you only need to disable the up and down keys of a text box
The Code is as follows:
NoExec = function (event ){Var k = event. which | event. k
This article mainly introduces how to trigger the function by pressing the left and right keys on the js keyboard. If you need it, please refer to it and hope to help you.
The Code is as follows:
First, you need to determine whether you want to disable the global control or the specified control. For example, I only need to disable the up and down keys of a text box.
Copy codeThe Code is as follows: NoExec = function (event ){
Var k = event. which | event. keyCode;
If (k = 13 | k = 38 | k = 40 ){
If ($ ("# atWinByArea"). attr ("id ")){
If (event. which) {// Firefox
Event. preventDefault ();
} Else {// IE, Chrome
Event. returnValue = fa
Code: At the time of execution, put the cursor in the specified place, in this case, click to run the cursor to the result area, paste the time is pasted to the cursor where the problem, such as the run script in the Web element input box input, you cannot move the cursor to another location#encoding =utf-8Import Win32APIImport Win32conClass Keyboardkeys (object):#模拟键盘按键类vk_code={' Enter ': 0x0D,' Ctrl ': 0X11,' V ': 0x56}@staticmethoddef keyDown (keyName):#按下按键Win32api.keybd_event (keyboardkeys
the keys on the keyboard.")Below, I press the A,B,C,D key Alone "); Input string
031
KeyPress (robot, Keyevent.vk_enter); Press ENTER to change lines
032
Robot.delay (3000); Wait 3 seconds.
033
KeyPress (robot, KEYEVENT.VK_A); Press the A key
034
Robot.delay (2000); Wait 2 seconds.
First you want to make sure you want to disable global or specified controls, such as I just disable the upper and lower keys of a text box
Copy Code code as follows:
noexec = function (event) {
var k = Event.which | | Event.keycode;
if (k = = | | k = = | | k = = 40) {
if ($ ("#atWinByArea"). attr ("id")) {
if (Event.which) {//Firefox
Event.preventdefault ();
else {//ie, Chrome
Event.returnvalue = false;
}
}
}
Downat (event);
}
Through the Oemkeyscan and Mapvirtualkey functionsOemkeyscan can get the scan code as well as the transition state, the state has shift is pressed, CTRL is pressed, Alt is pressed and so on.Mapvirtualkey Translate (map) a virtual key into a scan code or a character value, or translate a scan code into a virtual key code.1 DWORD SC, shift;2UnsignedCharvkey;3 CharA;4CString str ="ABC";5 for(inti =0; I//simulate the characters in the keyboard output str
Javascript to capture the keys pressed on the keyboard
A small demo uses js to capture the key on the keyboard and then display the corresponding code value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
JQuery implements page flip by keyboard arrow keys
This article will share with you the special effect of using jQuery to press the arrow key of the keyboard to flip pages. The code is very simple and the function is very practical. We recommend it to you and hope you will like it.
1. jQuery code:
The Code is as follows:
$ (Document). ready (function ()
= ediaeresis Ediaeresiskeycode 248 = idiaeresis Idiaeresiskeycode 249 = odiaeresis Odiaeresiskeycode = udiaeresis Udiaeresiskeycode 251 = ssharp question Backslashkeycode 252 = Asciicircum Degreekeyco De 253 = 3 Sterlingkeycode 254 = Mode_switch Use the KeyCode property of the event object to determine the input key value Eg:if (event.keycode==13) {var iekey=event.keycode ;//Get key value, digital form ofvar realkey=string.fromcharcode (Iekey)//Converts the key value in digital form to the real
= odiaeresis Odiaeresiskeycode = udiaeresis Udiaeresiskeycode 251 = Ssharp ques tion Backslashkeycode 252 = asciicircum Degreekeycode 253 = 3 Sterlingkeycode 254 = Mode_switch Use the KeyCode property of the event object to determine the input key value E G:if (event.keycode==13) {var iekey=event.keycode;//gets the key value, the digital form of thevar realkey=string.fromcharcode (Iekey)//Converts the key value in digital form to the real key alert (Realkey);} Key value corresponds to table a 0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.