Hi
I want to get the user's input key value, if user click "confirm" key , I will direct the page to some othe page, now i don't know how to confir user click the "confirm" key.
Hi
I want to get the user's input key value, if user click "confirm" key , I will direct the page to some othe page, now i don't know how to confir user click the "confirm" key.
It might help if you mentioned what platform you are developing for.
Perhaps something like this would work:
document.addEventListener('keypress', function(e){
alert(e.keyCode);
}, false);
This code should tell you the keyCode for the button. Then you can replace the alert with an if statement (let's say the confirm button produces a keyCode of 111):
if(e.keyCode === 111){
//redirect to other page
}
Your use of javascript should be limited to high end smart phones (i.e. iPhone/Android). On other devices, you will find any one of the following scenarios:
You can use tools like WURFL or DeviceAtlas to help determine the capabilities of the mobile device - but a good rule of thumb is avoid javascript unless you're sure the device can handle it.
Rgds, Kevin.