Results 1 to 3 of 3

Thread: Button press actions

  1. #1
    Join Date
    Aug 2013

    Exclamation Button press actions


    I want to create a JS-Code that can check what buttons people press.

    For example:

    When people wants more information about the site:

    if (press == Ctrl + I) {
    Alert('More Info Here!');

    Of course that code didn't work, so I tried something similar:

    if ((e.ctrlKey && KeyCode == 'i'.charCodeAt(1)) && area.offsetHeight) {

    alert('more info?');

    But also that don't work, what am I doing wrong?

    Thanks for reading,


  2. #2
    Join Date
    Dec 2005
    Not sure what is is that you are trying to do, but see how close this is...
    <button onclick="alert('More Info')">Forums</button>
    BTW: You should enclose your script between [ code] and [ /code] tags (without the spaces)
    to retain your code formatting and spacing, making it easier to read and copy/test.

  3. #3
    Join Date
    Oct 2013
    This got me thinking, and I was trying to figure it out while I was at work. However I ran out of time to get it working before I go out of town tonight.

    I was doing some digging and came across this.

    As per the standard, the attribute ctrlKey is only available on MouseEvents (like click, mouseover, etc.) but not HTMLEvents.

    Hope this helps.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center