943,771 Members | Top Members by Rank

Ad:
Feb 15th, 2008
0

Ctrl+t?

Expand Post »
Hi! I'm working on a graphics interface that is almost completely JavaScript. I want to assign a key combination to a function. For example: if the user hits Control+T, a new window would pop open.

Any tips?

Thanks!

Tom Tolleson
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Tom Tolleson is offline Offline
39 posts
since Oct 2007
Feb 16th, 2008
0

Re: Ctrl+t?

Reputation Points: 165
Solved Threads: 59
Posting Pro in Training
DangerDev is offline Offline
485 posts
since Jan 2008
Feb 19th, 2008
0

Re: Ctrl+t?

That seems to work for when the user presses any key. What I'm going for is a specific event that is a combination of the CTRL key with the letter T.

Here's what I have so far:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1.  
  2. function doSomething() {
  3. // The function code goes here
  4. }
  5.  
  6.  
  7.  
  8. event.ctrlKey("t") {
  9. doSomething;
  10. }

I'm just not sure how to express the combination of the CTRL press and the letter T press together.

Thanks!
Last edited by Tom Tolleson; Feb 19th, 2008 at 4:36 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
Tom Tolleson is offline Offline
39 posts
since Oct 2007
Feb 20th, 2008
0

Re: Ctrl+t?

Hi
evenif u will acheive this you will have problem, coz browser will also do some function in this case, like Mozilla will start new tab.
so try some thing else.
Why you want to do this, probably we can suggest some thing different.
Reputation Points: 165
Solved Threads: 59
Posting Pro in Training
DangerDev is offline Offline
485 posts
since Jan 2008
Feb 20th, 2008
0

Re: Ctrl+t?

Thanks for the reply.

I'm making this for an internal website (intranet) and it only needs to work in Internet Explorer.

I want the user to be able to pull up a pop-up window in which to write. But I cannot have a button on the webpage to activate it. I have to follow a strict design guideline.

Thanks again!
Reputation Points: 10
Solved Threads: 0
Light Poster
Tom Tolleson is offline Offline
39 posts
since Oct 2007
Feb 21st, 2008
0

Re: Ctrl+t?

Quote ...
it only needs to work in Internet Explorer.
it has solve your problem,
when you will press ctrl+t(or any other combination) it will return you perticular keyCode using which you can identify the key combination.
in IE you can capture keyCode using window.event.keyCode
use document.onkeypress to capture keypress event on whole document.
see this also.
hope this will solve your problem.

following example may help you:
html Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. document.onkeypress=function()
  5. {
  6.  
  7. alert(window.event.keyCode);
  8.  
  9. }
  10. </script>
  11. </head>
  12. </body>
  13. this example will work in IE 6
  14. </body>
  15. </html>
Reputation Points: 165
Solved Threads: 59
Posting Pro in Training
DangerDev is offline Offline
485 posts
since Jan 2008
Feb 21st, 2008
0

Re: Ctrl+t?

Hey! Thanks for the tip!

The following code does the trick:

document.onkeypress=function(){
if (window.event.keyCode == 20) {
alert('It Works!');
}
}

Thanks again!
Reputation Points: 10
Solved Threads: 0
Light Poster
Tom Tolleson is offline Offline
39 posts
since Oct 2007
Feb 21st, 2008
0

Re: Ctrl+t?

good i knew that, but i wanted you to try...any way nice job
Reputation Points: 165
Solved Threads: 59
Posting Pro in Training
DangerDev is offline Offline
485 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: drop down menu going behind flash element please help
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: insert a dev tag with in javascript





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC