By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,312 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,312 IT Pros & Developers. It's quick & easy.

Hotkey in asp.net page

P: n/a
I want to have following hotkey used in asp.net application, how to do this
especially for F5?

ESC
F3
F4
F5
F6
F9
F10
F12
Ctrl+J

Thanks,
-Billy zhang

Jul 8 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Billy,

As for web application, the key press/down events are handled by
client-side javascript. And you can register "onKeyDown", "onKeyPress"
script event for the <bodyelement or any other sub container(such as div
, span....). Here are some web articles mentioned this:

#Code Samples : Make Any Key A Hot Key
http://www.15seconds.com/howto/pg000086.htm

#How to Prevent Users to Press F5 key (Refresh button)
http://anujkrathi.blogspot.com/2007/...o-press-f5-key.
html

here is a simple test page I've used for demonstration:

=======================
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function hotkey(eventname)
{

if(eventname.keyCode == 116 )
{
alert("\nyou've pressed F5");

eventname.keyCode =505;// reset key code

return false; //return false to prevent refresh page
}

return true;
}
</script>
</head>
<body onkeydown="return hotkey(event);">
...................
============================

And for complete key code list in javascript key event, here is a good
reference:

#JavaScript KeyCodes List
http://www.aspdotnetfaq.com/Faq/What...or-JavaScript-
KeyDown-KeyPress-and-KeyUp-events.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <ht****@noemail.noemail>
Subject: Hotkey in asp.net page
Date: Mon, 7 Jul 2008 18:32:01 -0700
>
I want to have following hotkey used in asp.net application, how to do
this
>especially for F5?

ESC
F3
F4
F5
F6
F9
F10
F12
Ctrl+J

Thanks,
-Billy zhang

Jul 8 '08 #2

P: n/a
#How to Prevent Users to Press F5 key (Refresh button)
http://anujkrathi.blogspot.com/2007/...o-press-f5-key.

This link is invalid.

-Billy

"Steven Cheng [MSFT]" wrote:
Hi Billy,

As for web application, the key press/down events are handled by
client-side javascript. And you can register "onKeyDown", "onKeyPress"
script event for the <bodyelement or any other sub container(such as div
, span....). Here are some web articles mentioned this:

#Code Samples : Make Any Key A Hot Key
http://www.15seconds.com/howto/pg000086.htm

#How to Prevent Users to Press F5 key (Refresh button)
http://anujkrathi.blogspot.com/2007/...o-press-f5-key.
html

here is a simple test page I've used for demonstration:

=======================
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function hotkey(eventname)
{

if(eventname.keyCode == 116 )
{
alert("\nyou've pressed F5");

eventname.keyCode =505;// reset key code

return false; //return false to prevent refresh page
}

return true;
}
</script>
</head>
<body onkeydown="return hotkey(event);">
...................
============================

And for complete key code list in javascript key event, here is a good
reference:

#JavaScript KeyCodes List
http://www.aspdotnetfaq.com/Faq/What...or-JavaScript-
KeyDown-KeyPress-and-KeyUp-events.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <ht****@noemail.noemail>
Subject: Hotkey in asp.net page
Date: Mon, 7 Jul 2008 18:32:01 -0700

I want to have following hotkey used in asp.net application, how to do
this
especially for F5?

ESC
F3
F4
F5
F6
F9
F10
F12
Ctrl+J

Thanks,
-Billy zhang

Jul 8 '08 #3

P: n/a
Thanks for your reply Billy,

It seems the "html" extension is broken (by the line break):

the complete url is:

http://anujkrathi.blogspot.com/2007/...o-press-f5-key.
html

http://............/how-to-prevent-u...ss-f5-key.html

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: =?Utf-8?B?QmlsbHkgWmhhbmc=?= <ht****@noemail.noemail>
References: <84**********************************@microsoft.co m>
<#S**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Hotkey in asp.net page
Date: Mon, 7 Jul 2008 23:14:00 -0700
>#How to Prevent Users to Press F5 key (Refresh button)
http://anujkrathi.blogspot.com/2007/...o-press-f5-key
Jul 8 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.