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

Keydown, keypressed? input without inputbox

P: n/a
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

May 11 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Shirenseru said the following on 5/11/2006 5:29 AM:
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?
onkeydown/up on the window object.
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.
That's counter-intuitive.
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.


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/
May 11 '06 #2

P: n/a
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?

May 11 '06 #3

P: n/a
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.

May 11 '06 #4

P: n/a

"Shirenseru" <si*********@hotmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
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?


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>
May 11 '06 #5

P: n/a
ASM
Vic Sowers a écrit :
"Shirenseru" <si*********@hotmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
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?

Try something like:


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
May 11 '06 #6

P: n/a
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/ >
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.


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/
May 11 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.