Connecting Tech Pros Worldwide Help | Site Map

Keydown, keypressed? input without inputbox

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 11th, 2006, 09:35 AM
Shirenseru
Guest
 
Posts: n/a
Default Keydown, keypressed? input without inputbox

Hi,

I recently saw on a website, that there was a possibility that when
you're on a certain webpage,

and you type like " code " on your keyboard, that some function is
being called.
Does anyone has experience with this?

Cause i would really like some help..

I would like on a page, when typing " admin " that your current window
is being redirected to another page.

Like i have my html page. i type " google " and suddently i'm
redirected to www.google.com. The thing is, you don't see what you
type. Thats the whole idea behind this.

I hope people understand me,

Thanks in advance


  #2  
Old May 11th, 2006, 09:35 AM
Randy Webb
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox

Shirenseru said the following on 5/11/2006 5:29 AM:[color=blue]
> Hi,
>
> I recently saw on a website, that there was a possibility that when
> you're on a certain webpage,
>
> and you type like " code " on your keyboard, that some function is
> being called.
> Does anyone has experience with this?[/color]

onkeydown/up on the window object.
[color=blue]
> Cause i would really like some help..
>
> I would like on a page, when typing " admin " that your current window
> is being redirected to another page.[/color]

That's counter-intuitive.
[color=blue]
> Like i have my html page. i type " google " and suddently i'm
> redirected to www.google.com. The thing is, you don't see what you
> type. Thats the whole idea behind this.[/color]

And if you type it wrong?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  #3  
Old May 11th, 2006, 09:45 AM
Shirenseru
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox

Well i mean when you type

" adm " and then " p "

it should break. But when the followup is " admin " only then, the
page should open www.google.com

could you give me an example?

  #4  
Old May 11th, 2006, 09:55 AM
Shirenseru
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox

Hey i got it!

http://webdeveloper.earthweb.com/web...tem.php/822271

this was what i meant.

but instead of that msgbox i want to open a link in the same window.

  #5  
Old May 11th, 2006, 10:15 AM
Vic Sowers
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox


"Shirenseru" <silencer116@hotmail.com> wrote in message
news:1147340626.947072.77740@v46g2000cwv.googlegro ups.com...[color=blue]
> Well i mean when you type
>
> " adm " and then " p "
>
> it should break. But when the followup is " admin " only then, the
> page should open www.google.com
>
> could you give me an example?
>[/color]

Try something like:

<body onKeyPress="MonitorTyping()">
<h1>Blind Entry Test</h1>
<script type="text/JavaScript" defer>
buffer="";
function MonitorTyping() {
buffer = (buffer+String.fromCharCode(event.keyCode)).slice(-10);
if (buffer.slice(-4)=="admp") document.location = "http://Yahoo.com";
if (buffer.slice(-5)=="admin") document.location = "http://Google.com";
}
</script>
</body>


  #6  
Old May 11th, 2006, 02:45 PM
ASM
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox

Vic Sowers a écrit :[color=blue]
> "Shirenseru" <silencer116@hotmail.com> wrote in message
> news:1147340626.947072.77740@v46g2000cwv.googlegro ups.com...
>[color=green]
>>Well i mean when you type
>>
>>" adm " and then " p "
>>
>>it should break. But when the followup is " admin " only then, the
>>page should open www.google.com
>>
>>could you give me an example?
>>[/color]
>
>
> Try something like:[/color]

this bellow works in my FireFox

<body>
<h1>Blind Entry Test</h1>

<script type="text/JavaScript">
buffer = "";
onkeyup = MonitorTyping;
function MonitorTyping(e) {
e = e || event;
buffer += String.fromCharCode(e.keyCode).toLowerCase();
if (buffer.indexOf("admp")>=0) location = "http://Yahoo.com";
if (buffer.indexOf("admin")>=0) location = "http://Google.com";
</script>

</body>
</html>


--
Stephane Moriaux et son [moins] vieux Mac
  #7  
Old May 11th, 2006, 04:05 PM
Randy Webb
Guest
 
Posts: n/a
Default Re: Keydown, keypressed? input without inputbox

Shirenseru said the following on 5/11/2006 5:50 AM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

<URL: http://www.safalra.com/special/googlegroupsreply/ >
[color=blue]
> Hey i got it!
>
> http://webdeveloper.earthweb.com/web...tem.php/822271
>
> this was what i meant.
>
> but instead of that msgbox i want to open a link in the same window.
>[/color]

Change this line of code:

var code = "code"; //no spaces no special chars

To something like this:

var code="admin";

And then, change this line of code:

alert("You typed the code!")

to this:

window.location = 'http://www.google.com/';

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.