473,382 Members | 1,329 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,382 software developers and data experts.

Capturing Ctrl N

Hi,
Is there any way to capture the action Ctrl+N (whether it in a hidden
button or keyword - doesn't matter) in html, javascript or php? I
appreciate any suggestions.
Thank you and kind regards
Bils
Jul 23 '05 #1
6 4924
Bilal wrote:
Is there any way to capture the action Ctrl+N (whether it in a hidden
button or keyword - doesn't matter) in html, javascript or php? I
appreciate any suggestions.

HTML: no
PHP: no
javascript: I have no idea

--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 23 '05 #2
Ivo
"Bilal" wrote
Is there any way to capture the action Ctrl+N (whether it in a hidden
button or keyword - doesn't matter) in html, javascript or php? I
appreciate any suggestions.


Asking if such things are possible in any other language than client side
script, shows a great lack of understanding. I tried (in IE6) the following
<script type="text/javascript">
onkeydown=keyd;
function keyd(e) {
e=e||window.event;
k=String.fromCharCode(e.keyCode).toLowerCase();
if( k=="n" && e.ctrlKey) alert('Nnnn');
if( k=="o" && e.ctrlKey) alert('Oooh');
if( k=="l" && e.ctrlKey) alert('Lalala');
return false;
}
</script>
but only get the alert for L and O, not for N. I guess there 's a reason for
that.
You don't say what you want the ctrl+N for. If it is to stop people opening
new windows while on your site, please reconsider. There are always ways to
bypass any script you write and restore normal browser behaviour.
HTH
Ivo
Jul 23 '05 #3
"Pedro Graca" wrote:
Bilal wrote:
Is there any way to capture the action Ctrl+N (whether it
in a hidden button or keyword - doesn't matter) in html,
javascript or php? I appreciate any suggestions.


HTML: no
PHP: no
javascript: I have no idea


In javascript the answer is yes and no. In IE, for example, if contents
of the document have focus (so are receiving keyboard input) then it is
possible to intercept Ctrl+N, but if the window has focus the keystrokes
go straight to the browser and scripts running in the document never get
to hear about them. Gecko browsers seem to allow all keystrokes to be
intercepted (though not necessarily cancelled) and Opera browsers tend
to keep their keyboard shortcuts entirely to themselves. So on the whole
it is probably not worth the effort to try to detect Ctrl-N as the
effort will predictably fail at least often enough to fail to address
whatever motivates the question.

The result of Ctrl-N in Windows IE is to open a new browser instance
(with full chrome) and showing the same page/URL as the old one (and
associated with the same user session), so the reason for asking this
question is usually a realisation that such an action will have harmful
consequences for a server-side system. But this is normal behaviour form
web browsers (and unavoidable) so the solution is to fix the server-side
code so that it can cope with the normal behaviour of client browsers.

Richard.
Jul 23 '05 #4
bj****@hotmail.com (Bilal) wrote in message news:<f9**************************@posting.google. com>...
Hi,
Is there any way to capture the action Ctrl+N (whether it in a hidden
button or keyword - doesn't matter) in html, javascript or php? I
appreciate any suggestions.


Sometime ago, we had a similar discussion
<http://groups.google.com/groups?selm=abc4d8b8.0311212053.4be98d39%40posting .google.com>

In short, in PHP there is no "direct" way of trapping the "Ctrl+N"
as it is server-side.

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 23 '05 #5
On Wed, 2 Jun 2004 10:43:48 +0000 (UTC), "Richard Cornford"
<ri*****@litotes.demon.co.uk> wrote:
Gecko browsers seem to allow all keystrokes to be
intercepted (though not necessarily cancelled) and Opera browsers tend
to keep their keyboard shortcuts entirely to themselves.


Er, so you can guess where people navigate too if they type in the
URL?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 23 '05 #6
Jim Ley wrote:
Richard Cornford wrote:
Gecko browsers seem to allow all keystrokes to be
intercepted (though not necessarily cancelled) and Opera
browsers tend to keep their keyboard shortcuts entirely
to themselves.


Er, so you can guess where people navigate too if they
type in the URL?


In principle I suppose you could, though it was some considerable time
ago I was testing this and there have been a lot of Mozilla releases in
the meanwhile (so it may no longer be true). And I didn’t try
specifically capturing keystrokes aimed at the location bar because I
was experimenting to see if there was any way of preventing the use of
bookmarked javascript URLs so removing the location and menu bars from
the window was the obvious first barrier to their use.

I remember at the time thinking that it was poor that Mozilla was
letting a script within a document intercept and cancel keyboard
shortcuts.

Richard.
Jul 23 '05 #7

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

Similar topics

5
by: Bilal | last post by:
Hi, Is there any way to capture the action Ctrl+N (whether it in a hidden button or keyword - doesn't matter) in html, javascript or php? I appreciate any suggestions. Thank you and kind regards...
3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
4
by: cs | last post by:
How can I capture the events leading to my windows application crashing? would a big try catch around the Application.Run() do the job? in my head that launches a thread and if that thread crashes...
2
by: Phil Galey | last post by:
I'm using the ProcessCmdKey event to capture various keys that are pressed. However, I'm having trouble capturing the combination of the CTRL key and, say, the DOWN key. If I just press the CTRL...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
2
by: senfo | last post by:
Hello all, To help alleviate human error, I'm developing an application that uses a barcode reader to fill in a value in a TextBox control. The barcode reader is connected to the PC through the...
2
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
I have a tabcontrol where I want to capture the CTRL+C key combination. My tabcontrol has on its tabpages some treeView controls. My intention is to intercept the event of pressing the CTRL+C when...
1
by: Sendil kumar | last post by:
When I do a Ctrl-C(copy) on a text, the text was not copied. By narrowing down the problem I found that VC++ message map is not capturing the Ctrl-C key press event(Only captures the first key press,...
2
by: John | last post by:
Hi How can I capture control keys Ctrl-A, Ctrl-B, Ctrl-C etc. in a form? Thanks Regards
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.