473,395 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

window.onkeydown but not for a specific div or form

I have set window.onkeydown which works fine.
One of my shortcut keys is "n", so a user can not type "n" in forms.
How do I solve that?

Thanks,
Jacob
Jul 23 '05 #1
5 4335
Jacob Friis Larsen wrote:
I have set window.onkeydown which works fine.
One of my shortcut keys is "n", so a user can not type "n" in forms.
How do I solve that?

Thanks,
Jacob


<script type="text/javascript">

document.onkeydown = function(e)
{
var tgt = null;
if ((e = e || window.event)
&& (tgt = e.target || e.srcElement)
&& tgt.type
&& /text/.test(tgt.type))
return true;
else
{

//stuff here

}
}

</script>

Jul 23 '05 #2
Could someone please explain what this does?

Thanks,
Jacob

Jul 23 '05 #3
Jacob Friis Larsen wrote:
Could someone please explain what this does?

Thanks,
Jacob
Someone here. Best I could do, based on this detailed description:
I have set window.onkeydown which works fine.


document.onkeydown = function(e)
{
var tgt = null;
if ((e = e || window.event) //get event object
&& (tgt = e.target || e.srcElement) //get trigger element
&& tgt.type //has 'type' property?
&& /text/.test(tgt.type)) //'text' or 'textarea'?
return true; //end processing
else
{

// shortcut code

}
}

</script>

Jul 23 '05 #4
Thanks alot RobB :)
Kind regards Jacob

Jul 23 '05 #5
What if a user press ' to search for a link in Firefox?
I see this as a problem for gmail too.
Can that be fixed?

Thanks, Jacob

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brad Jones | last post by:
<Previously posted in microsoft.public.dotnet.framework.windowsforms> Hi all. Any suggestions here would be appreciated. Thanks for reading. I'm primarly a C++ developer but I've been trying to...
5
by: Russell Campbell | last post by:
I was using onKeyDown to change Enter to Tab. However, in a textarea, this prevents a CRLF from being entered and just moves you to the next field. So I thought if I put an onKeyDown on the...
32
by: Eli | last post by:
How can I POST a form into a new window where I control the size and other attributes of the new window? Also. Are there any implications, perhaps due to browser security (Interne Explorer?)...
5
by: Dave Henson | last post by:
Hi I am checking a site for accessibility and Dreamweaver suggests making sure that the menu is accessible via keyboard as well as mouse (i.e device-independent). A question has arisen which is...
3
by: news.microsoft.com | last post by:
Hi all. I have a problem eith OnKeyDown it work fine when on the form there are nothing, but when I am adding toolbar it does not work properly, I receive Keys.Up event for 2 second time Can...
8
by: Someone | last post by:
Hi, I wish to use a dictionary.com search box and want the results of a search to open in a new window. Is there a way to do this using their code? The copy and paste code is provided below. ...
1
eboyjr14
by: eboyjr14 | last post by:
I have this UserScript for Grease monkey. but I can't get the onleydown event to fire in FIREFOX only. I've looked everywhere! // ==UserScript== // @name iGoogle Suggest //...
8
by: Tony Johansson | last post by:
Hello! I wonder can somebody explain when is it suitable to use these methods OnKeyUp, OnKeyDown and OnKeyPress because these raise an event. These are located in class UserControl. If these...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.