Implementing ASCII code to PHP

They have: 1 posts

Joined: Jun 2012

Can anyone tell me that how to implement ASCII code in PHP? I need it to detect that which key has been pressed by user and then take necessary action against that key press event.
Kindly help me as soon as possible.

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Assuming you are talking about on a web page, this cannot be done with PHP alone.

PHP executes on the server, and it's output goes to the browser, the only interaction you get is when a page request is sent to the server.

For this you will need to use Javascript, which executes in the browser (thus can detect what the user is doing). Then using AJAX, when it detects you press a key, it would need to send a page request to the server and then process the results (usually, the results are not an actual web page, but data formatted in a way you prefer, so that the javascript on the page can update the portions of the page you want to change.

A good thing for this would be to learn jQuery, as once you get the hang of that, it can make things a lot easier to get going, and be the most compatible across browsers and OS's

-Greg

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.