...

View Full Version : Hot keys with alt or ctrl mod. to link to url ?



Scubanaked
08-19-2002, 03:30 AM
I need some help with an issue that for the last week has been my nighmare. I have
been programming html for two years and php/mysql for about eight monthes, so I'm pretty new at this. Anyways, I have been searching and
reading and trying very hard to implement java hotkeys into a simple html page. I have found about five ways to do the hot key itself ( that
work). Although I wouldn't say I have a very strong grasp of which thing in the script are variables, which things are functions and which
things are java commands. Anyways, I have also found some applets that test wether a modifier is present.
I am having serious trouble putting the two together. This is the closest I've gotten:

<script language="JavaScript1.2">
if (document.layers)
document.captureEvents(Event.KEYPRESS)
function backhome(e)
{
if (document.layers)
{
if (evt.isAltDown())
{
if (e.which==117)
window.location="http://www.internetfresno.com/madera/index.php?app1=takemsg&login=<?echo$login;?>"
}
}
else if (document.all)
{
if (evt.isAltDown())
{
if (event.keyCode==117)
window.location="http://www.internetfresno.com/madera/index.php?app1=takemsg&login=<?echo$login;?>"
}
}
}
document.onkeypress=backhome

</script>


But it doesn't work.
I would like this to work in Internet explorer 5 and Netscape 4.75 would be a bonus, but not necessary. All I really need is for when the user
presses either Alt-U or Ctrl-U or even a function key for an a href to fire a simple link. The cursor is positioned in a text box, so a normal key won't do.
I've poured through page after page of java scripts. I
would be in your debt if you could help me with this.
Enjoy my site. www.scubanaked.com (it's not porn)
and email me at brian@scubanaked.com
Thank you
Brian Kempe
Fresno California

jkd
08-19-2002, 05:30 AM
document.onkeypress = function(event) {
if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
// do something for CTRL-U
}
}

I believe should accomplish what you want in NS6+ and IE4+.

Scubanaked
08-19-2002, 05:48 AM
I am trying the following in IE 5.5 and am not getting anything for Ctrl-u:

<script language="JavaScript1.2">


document.onkeypress = function(event) {
if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
}
}

</script>

What am I missing.
http://www.internetfresno.com/madera/shorthotkey3.html

jkd
08-19-2002, 06:07 AM
Oops:

document.onkeypress = function(event) {
if (!event && window.event) event = window.event;
if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u') {
window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
}
}

I think that should work.

Scubanaked
08-19-2002, 06:43 AM
I uploaded this
<script language="JavaScript">
document.onkeypress = function(event)
{
if (!event && window.event) event = window.event;
if (event.ctrlKey && String.fromCharCode(event.keyCode).toLowerCase() == 'u')
{
window.location="http://www.internetfresno.com/madera/index.php?app1=useradmin"
}
}
</script>
www.internetfresno.com/madera/shorthotkey3.html
I'm at a loss
But, believe me I appreciate your attention to my deliema
Brian : )

Scubanaked
08-21-2002, 02:02 AM
<a href="http://www.url.com" onfocus="window.location='http://www.url'" accesskey="A">
<u>A</u>nother link
</a>

beetle
08-21-2002, 03:17 AM
You can also check this page (http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onkeypress.asp) for more info



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum