Hi I am new in PHP. I have one query is it possible to give short cut keys like f1, f2 etc.. for saving data, opening any page directly by pressing button. please reply me, I am waiting

Recommended Answers

All 2 Replies

Most of the function keys are already reserved by the browser for other tasks. So if you assigned an action to, for example, the F5 key, you'll end up refreshing the browser window.

It may be possible to stop the default behavior of the button -- I'm not sure. Regardless, what you are looking for is in the domain of JavaScript, not PHP, since PHP takes place on the server-side, whereas button presses are client-side. You may want to look into jQuery. The event.preventDefault() may help you accomplish your goal. Keep in mind that:
1) users may get annoyed if you take away their ability to use the function key shortcuts for what they are intended for by the browser, and
2) users on browsers that do not support JavaScript or that have JavaScript turned off will not be able to use these shortcuts.

I hope that helps.
- EF

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.