user1783032 user1783032 - 4 months ago 7x
SQL Question

Is there any code for saving characters automaticaly which are pressed by user to database -without send button-

It can be JavaScript, Ajax or PHP. A need a real code parts or good guide. Is there any link?

Purpose of this: I am planning a keyboard game which is running with characters which are pressed by user. If user press the button a, I have to sent send this data to MySQL database. Is this possible? If yes, with which code?


If your using jQuery framework you can use keypress event (if you're not using jQuery you can still use a keypress events but jQuery makes it easier!)

From the docs:

$("#target").keypress(function(event) {
  if ( event.which == 13 ) {

e.which will give you access to the keycode the user pressed. With this you can easily respond to specific key presses. 13 is a javascript keyboard code for 'enter' So perhaps you want to save all input to a variable that user types on the keyboard and when enter is typed you can send that data using ajax. jQuery makes this very simple.