onkeydown

simple javascript keystroke count

无人久伴 提交于 2019-12-07 23:00:43
I'm developing an online study/survey where I need to count the number of keystrokes that a participant makes. I am asking them to type lrlrlrlrlrlrl... in a text field to simulate walking. Turns out many of the participants (as evidenced by the time spent on the task) are copying and pasting. I need something that will count keystrokes so I can identify participants who completed the task as requested. The study is programmed in Coldfusion and I was thinking about some sort of javascript/onkeydown/hidden file field combination, but I am not really a programmer. Any help would be appreciated.

onkeydown and onkeyup events don't work on Internet Explorer 8

拈花ヽ惹草 提交于 2019-12-07 12:24:36
问题 My code works without problems on IE9/IE10, FF, Chrome and opera but on older Internet Explorer no Keyboard input is handled. I have the following code for handling events. It should only fire when a new button is pressed. lastEvent = void 0; heldKeys = {}; window.onkeydown = function(event) { if (lastEvent && lastEvent.keyCode === event.keyCode) { return; } lastEvent = event; heldKeys[event.keyCode] = true; switch (event.which) { case 80: return myamp.userInput("positiv"); case 81: return

How do I simulate hover with Javascript on keydown?

有些话、适合烂在心里 提交于 2019-12-07 04:37:49
问题 First of, I'd like to use only native JavaScript to complete this task. Let's say I am to make a custom dropdown, and the HTML code looks kind of like this. <div class="dropdown"> <span class="dropdown-label" style="display:block">Select a thing</span> <ul class="dropdownItemContainer"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> <li>Item 6</li> </ul> </div> In the CSS file I have something close to this: ul.dropdownItemContainer li:hover { background-color

CKEditor key event not updating text properly

拜拜、爱过 提交于 2019-12-05 22:48:11
I have the following code to automatically update the content inside a div when the user types it inside a CKEditor textarea: CKEDITOR.instances.editor.on("key", function(e) { var preview = document.getElementById('some-div'); preview.innerHTML = CKEDITOR.instances.editor.getData(); }); The problem is that if I type in "Hello world", in the div it appears "Hello worl" and the "d" doesn't appear until another key is pressed. And I would want the same content in both places. Thanks in advance! I solved it handling the key event in a different way. You can see it below: CKEDITOR.instances.editor

How do I simulate hover with Javascript on keydown?

点点圈 提交于 2019-12-05 10:43:24
First of, I'd like to use only native JavaScript to complete this task. Let's say I am to make a custom dropdown, and the HTML code looks kind of like this. <div class="dropdown"> <span class="dropdown-label" style="display:block">Select a thing</span> <ul class="dropdownItemContainer"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> <li>Item 5</li> <li>Item 6</li> </ul> </div> In the CSS file I have something close to this: ul.dropdownItemContainer li:hover { background-color: #FF0000; } Yeah, there's really no dropdownish behavior, but it's not the point of discussion

Minimize activity on back key press

我只是一个虾纸丫 提交于 2019-12-05 02:13:55
OnBack Key press i want to minimize the application, How can i do this??? public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //Here i want to put minimize code.. pls give me this statement return true; } return super.onKeyDown(keyCode, event); } Thanks public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { this.moveTaskToBack(true); return true; } return super.onKeyDown(keyCode, event); } This will send the activity to the background. See documentation for further reference. 来源:

Detect Ctrl + C and Ctrl + V in an input from browsers

耗尽温柔 提交于 2019-12-04 09:02:54
I am using the direct following and I do not detect the copy and paste with the keys inside the input, would someone know how? Thank you! export class OnlyNumberDirective { // Allow decimal numbers. The \, is only allowed once to occur private regex: RegExp = new RegExp(/[0-9]+(\,[0-9]{0,1}){0,1}$/g); // Allow key codes for special events. Reflect : // Backspace, tab, end, home private specialKeys: Array<string> = [ 'Backspace', 'Tab', 'End', 'Home', 'Delete', 'Del', 'Ctrl', 'ArrowLeft', 'ArrowRight', 'Left', 'Right' ]; constructor(private el: ElementRef) { } @HostListener('keydown', [ '$event

Calling javascript functions in a webview from activity class [closed]

坚强是说给别人听的谎言 提交于 2019-12-04 07:37:52
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center . Closed 6 years ago . Edit: This snipped worked in the end. I had been trying this before but was actually experiencing a scoping issue with my javascript. I had appBack() defined in document.onready. Simply re-scoping that function to *window.*appBack = function(). Done the business. Hope this helps someone. public boolean onKeyDown

Handle key using javascript onkeydown

给你一囗甜甜゛ 提交于 2019-12-04 05:29:15
问题 I have this code function verifyKey(e) { var keycode; if (window.event) keycode = window.event.keyCode; else if (e) keycode = e.which; regex=/[1-9]/; if(regex.test(keycode)) return true; else void(0); } in the html I added an input and I add the onkeydown event onkeydown="verifyKey(event);" I like to verify the key before it display on the text If the key is a number or coma(,) or full stop(.) then accept the key else refuse it Thanks 回答1: Here in your code you are testing the regular

Javascript: Keydown Event: “Up” arrow key preventing further arrow-key Keydown events? (answered: keyboard ghosting)

流过昼夜 提交于 2019-12-04 03:10:00
问题 I've found a lot of related questions (here and elsewhere), but haven't found this one specifically. I'm trying to listen for keydown events for the arrow keys (37-40), however when using the arrow keys in a certain order, subsequent arrow do not generate "keydown" events. Example: http://blog.pothoven.net/2008/05/keydown-vs-keypress-in-javascript.html At that page, click in the "type here ->" box. Press and hold right arrow key: table updates to keycode 39 While continuing to hold right