I've created a reset button that resets all the data on my search criteria form. I've made it so my Search buttons fires when enter is pressed, but I'm wondering:
How can I make the RESET button fire when BACKSPACE is pressed?
Thanks!
Take a look at the form's OnKeyPress event: http://msdn.microsoft.com/en-us/library/aa213952%28v=office.11%29.aspx
Related
is there a way to create a HTML button, which simulates space-bar pressing on the keyboard?
So, whenever I press space bar or click the button, I get the same result.
Thanks in advance.
This is related to How is the default submit button on an HTML form determined?
In my web app's design the user should be able to directly submit the form by pressing enter in a text input, in which case, none of the buttons in that form should be submitted as they have other functions. To avoid the default button problem, I handles the keydown event and submitted the form programmatically.
When I tested this in Firefox, it seems the first button in the form is pressed on the enter key. The simple solution is to disable that button in the keydown event handler.
Chrome, however, seems to 'intelligently' choose the first non-disabled button as the default button and will submit using that button even if that button will be immediately disabled by the keydown handler.
The effect can be tested using this jsFiddle. In Firefox, after the "first" button has been disabled by the checkbox, enter press in the input will only cause one submit. In Chrome, there will always be two submits, one from keydown and the other from button press, even after both buttons have been disabled!
This forces me to either change all keydown handlers in my code to return false or handle all button clicks and check if the button is disabled. Neither seems to be good code.
Any better suggestions?
May be you can hook it on blur. Try this:
<input type="text" ... onblur="submit();" />
Let's say I have an onFocus event for a text box. That event triggers when the user tabs into that box, as expected. But it also seems like the event triggers when the box is selected, and then the window is covered and then uncovered, by switching tabs, opening then closing another application, etc. Is there a way to make it so that the event triggers only by tabbing (or mouse-clicking) the text box, and NOT by covering then uncovering the window?
You can use an onClick event. This will only trigger the event on the click though, not tabbing.
You could also use onKeyDown which would trigger on any key press, but would also trigger when the user tabbed away from the textbox.
http://jsfiddle.net/kBzAu/2/
when one goes away from page, you may use window.document.onblur=function(){disable all onFocus};
and re activate them with window.document.onfocus=function(){enable all onFocus};
Can SWFAddress "sense" when a user has pressed the browser back button?
I know it can fire off EXTERNAL_EVENTS, but...does it do this for specific buttons?
Not really, the only awareness that swfaddress has of the user pressing the back button is that the address in the browser's location bar changes (represented by the window.location object in javascript). It detects that change by checking the window.location object on a regular interval.
When the window.location object changes, but swfaddress didn't trigger the address change, it fires an EXTERNAL_CHANGE event. This could be caused by the user typing in a new anchor into the location bar, hitting the back/forward buttons, or several other things. There's no way to do something like putting an event listener on the browser's back button.
I have a keyUp event in button1 and EnterEvent in button2
When i press button1 and use my up arrow automatically control is navigating to Enter Event of button2 after entering into the KeyUp event of button1
Feels something fishy; Please help !!
Just to be clear, the KeyUp event doesn't refer specifically to the Up key on your keyboard. It is an event that triggers anytime you release any key. The keyboard events are KeyDown (when you push any key down), KeyPress (after KeyDown), and KeyUp (when you let go of the key). If you hold down a key, the KeyDown and KeyPress events trigger repeatedly until you let go, at which point KeyUp fires. (Note: pressing the Enter key on a control that is set as Default or pressing the Esc key on a control that is set as Cancel will NOT trigger any of the Key events for those controls.)
Also, the Enter event doesn't refer to the Enter key, it refers to anytime you enter that control, whether by clicking your mouse into it or moving to it via the keyboard.
In light of all of this, here's what looks to be happening:
You press and release the Up Arrow on your button1, triggering button1's KeyUp event. The focus then moves to button2 (because you pressed the Up arrow key, a navigation key) and triggers the Enter event of button2 (because you just entered button2).
From MSDN
"The Enter event occurs before a control actually receives the focus from a control on the same form."
sounds like its doing the right thing, when you press the up arrow focus is being switched to the next button (Button2) which is causing the Enter event to fire.