Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Textbox Enter Key Question (Sugarcube)?

I have the textbox input set up so that when you hit the Enter key it goes to the designated passage. What I am trying to accomplish is that when you hit the Enter key it plays a sound and then goes to the designated passage. I have accomplished this with the button macro, so that it plays a sound when the button is clicked. I just can't seem to figure out how to do this with the Enter key. Is this possible? Thank you in advance.

InsertCoin25

Comments

  • It is possible.  I assume that you're using one of the various audio macros (in the future, give details please), so it's probably best to continue with that.  It will also probably be easier to extend the existing focusing code you have to achieve this.  So, with that in mind, and assuming your using something like the code I gave you before, try the following (you will have to customize this for the specific macro invocation you need).

    FIND:

    if (input !== null) {
    input.focus();
    }
    REPLACE WITH:

    if (input !== null) {
    input.focus();
    jQuery(input).keypress(function (evt) {
    // if Return/Enter is pressed play a sound
    if (evt.which === 13) {
    Wikifier.wikifyEval('<<AUDIO MACRO INVOCATION HERE>>');
    }
    });
    }
    Replace &lt;&lt;AUDIO MACRO INVOCATION HERE&gt;&gt; with the specific macro invocation you require.
  • Sorry about the details will do next time I need help. You were dead on with the code. Works perfectly using the HTML5 audio macro. Thanks again for the help. You truly are a master of your craft.

    Take Care
    InsertCoin25
Sign In or Register to comment.