onkeypress

Java Swing: Do something while the key is being pressed

↘锁芯ラ 提交于 2019-12-07 10:56:01
问题 Im using a KeyAdpater to get the events and the method addKeyListener and works fine. The problem is that when a press the key, the action ocurrs only once and not while its being pressed, after 3-4 secs holding down the key the action occurs all the time which is what I want. I'd want to know if there is good way to do the action all the time the key is being pressed from the very begining , not after 3-4 seconds holding down. I thought on the next solution, but maybe there is already an

Java Swing: Do something while the key is being pressed

安稳与你 提交于 2019-12-05 15:17:35
Im using a KeyAdpater to get the events and the method addKeyListener and works fine. The problem is that when a press the key, the action ocurrs only once and not while its being pressed, after 3-4 secs holding down the key the action occurs all the time which is what I want. I'd want to know if there is good way to do the action all the time the key is being pressed from the very begining , not after 3-4 seconds holding down. I thought on the next solution, but maybe there is already an implemented way to do it: public abstract class MyKeyAdapter extends KeyAdapter{ private boolean isPressed

Detecting command + keystroke in Safari

拥有回忆 提交于 2019-12-05 15:06:13
I'm trying to intercept the command + keystroke in Safari. I've added an event handler as follows: document.onkeypress = handleKeyPress; function handleKeyPress(event) { if ("+" === String.fromCharCode(event.charCode) && event.metaKey) { // my code here return false; } return true; } When I hit command shift = ( shift = is + on my US keyboard), the if statement does not return true. If I remove the event.metaKey portion of the if statement and hit shift = , the if statement does return true. Also, if I change the matching string from "+" to "=" and hit command = (with or without the shift key)

jQuery .keyPress() - How to get value of input which triggered event?

淺唱寂寞╮ 提交于 2019-12-05 10:55:08
Trying to do some jQuery validation (without the plugin - please no answers like "Just use the validate-js plugin"). I'm wiring up a client-side event handler keypress for each "required field" on doc ready: $(document).ready(function() { $('#myform input.required').each(function() { $(this).keypress(onRequiredFieldKeyPress); }); }); Which correctly fires this event on each keypress: function onRequiredFieldKeyPress() { if ($(this).val().trim() == '') { $(this).next('em').html('*').show(); // show req field indicator } else { $(this).next('em').html('*').hide(); // hide req field indicator } }

XPages - onkeypress event not triggering click properly

烂漫一生 提交于 2019-12-05 10:26:45
I created a search field (id:searchField) and a search button (id:searchButton) using Xpages Custom Controls. I added an onkeypress event on the search field such that it will trigger a click to the searchButton. The searchButton will then reload the page but with url parameters coming from the search field. The problem is that the page reloads but the search parameters are not added to the URL when I press ENTER in the search field , but works properly when I press searchButton. Here are the codes I used: (code added to the onkeypress of searchField) if (typeof thisEvent == 'undefined' &&

How do I disable Firefox's “Search for text when I start typing” on pages with keyboard shortcuts?

心不动则不痛 提交于 2019-12-04 15:39:26
问题 Some web pages such as GMail and Reddit(with the Reddit Enhancement Suite) have useful keyboard shortcuts that I'd like to use. However, whenever I start typing on one of these pages, the first onkeypress event fires, but then the "Search for text when I start typing" search bar opens and blocks further keys. I don't want to disable "Search for text when I start typing" as I use it on most other web pages. Is there any way to selectively disable it, or to make a keyboard shortcut/bookmarklet

Javascript fires two events - onkeypress and onclick

一曲冷凌霜 提交于 2019-12-04 08:27:05
Problem is when I press a key over a radio button, element MyFunc fires twice - once for "onkeypress" event, another time for "click" event. Question "Why?" I need to handle this by two different ways, but now I can not recognize what initial event was. When I click a mouse it fires just for "click" event. <ul> <li> <input type="radio" onkeypress="MyFunc(event, this)" onclick="MyFunc(event, this)" name="myList" id="MyId_1" />Topic 1 <input type="radio" onkeypress="MyFunc(event, this)" onclick="MyFunc(event, this)" name="myList" id="MyId_2" />Topic 2 </li> </ul> function MyFunc(e, obj) { alert

Excluding form fields from keypress handler assigned to body

陌路散爱 提交于 2019-12-04 04:27:21
问题 I have a keypress handler on a web page assigned to the body element. I really do want it to be active anywhere in the web page. Or so I thought. The keypress events in textual input forms also activate the body handler, which makes sense, but which I don't want. Ideally, I'd like to keep the keypress handler assigned to the body element and somehow exclude just the input forms. Is there any way I can stop the event at the input level and prevent it from propagating to body? (Or is that even

Storing the line number of all the occurrence of particular character in javascript

你离开我真会死。 提交于 2019-12-04 02:13:28
问题 I am following this link Find out the 'line' (row) number of the cursor in a textarea. I want to store the line number of all the occurence of "{" in array while user write in textarea. I want to display the array content after it. Here is source code , I have tried: <textarea rows="10" cols="100" id="editor" onkeypress="hello(event);" ></textarea> <div id="lineNo"></div> <script> function hello(e) { var keyp=e.charCode; var c=0,i; var arr=new Array(); if(keyp=='123') { var arr[c++]

JavaScript key handling and browser compatibility

核能气质少年 提交于 2019-12-03 17:19:50
问题 I'm working on key handling in Javascript. I have done some research and I'd like to know whether I have a correct understanding of key handling. KeyDown/KeyUp Event The key down and key up events are supported by IE7+ and Firefox 3.5+ I didn't check the earlier versions of the browsers, but I guess that they also support these events. Is it correct to say that each key on the keyboard will always have a keycode. CharCode CharCode value is available on the keypress.Majority of the keys will