473,480 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript : create shortcut to give keyboard focus on html elements

1 New Member
Hi,

I am new in javascript,

I am currently building a simple website,
and I like to make a keyboard shortcut
so when someone press ctrl-1,
it will give keyboard focus to a textbox

can anyone help me?
Sep 13 '07 #1
2 1740
acoder
16,027 Recognized Expert Moderator MVP
Moved to forums section. Please do not post questions in the Articles section.
Sep 13 '07 #2
dmjpro
2,476 Top Contributor
Moved to forums section. Please do not post questions in the Articles section.
Have a look at the example.

Expand|Select|Wrap|Line Numbers
  1. function getKeyCode(e)
  2. {
  3.  var key_code = (typeof e.which) ? e.which : e.keyCode;
  4.  //In IE 'keyCode' is valid and in Mozilla based browsers 'which' is valid
  5.  var alt_key = e.altKey, ctrl_key = e.ctrlKey;
  6. }
  7.  
Expand|Select|Wrap|Line Numbers
  1. <input type = text onkeydown = "getKeyCode(event)">
  2.  
Good Luck.

Kind regards,
Dmjpro.
Sep 13 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6908
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7044
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
7084
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...
1
6739
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
5337
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,...
1
4779
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
563
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
181
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.