Click here to Skip to main content
13,055,629 members (53,635 online)
Rate this:
Please Sign up or sign in to vote.
What is the best way to create
a search control which has a textbox(to enter search string) with Up and down arrow to traverse up and down node of trees.Also when pressing 'enter' after giving string in search box , it should search in down direction of nodes.
one issue that i am facing as of now is when i press enter it is submitting the form. I did try event.preventdefault but it is still not working.
Posted 26-Apr-13 10:37am
Sergey Alexandrovich Kryukov 26-Apr-13 16:41pm
No, it shouldn't. I mean Up and Down keys are already reserved for basic browser functionality; you should use some other keys. "Not working" is not informative.
devcode007 30-Apr-13 15:34pm
hey....i apologize for not being clear on this one. By Up and down arrow i meant, i will put arrow image near search control which user can click to search.
And about event.preventdefault : i am calling this after capturing keystroke for Enter which means once enter is clicked i give call to my search method and also fire event.preventDefault so that it do not submit the form.
Somthing like this :

Find <input id=\"FindID\" type =\"text\" onkeydown =\"fsearchkey(event)\" önkeyup =\"fsearchkey(event)\" > </input>";

function fsearchkey(event) {
if (event.keyCode == 13) {
I have tried Keypress event as well.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Even though jQuery is tagged, I don't see that you used it. I see no problem in using jQuery .keypress():[^].

Again, you should never use Up and Down keys, as they are reserved for scrolling, cursor motion in cursor mode and more. Use something else, maybe Ctrl+Up, Ctrl+Down.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 30 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100