Skip to main content
Participating Frequently
July 8, 2020
Question

TEB and Function Key JS code

  • July 8, 2020
  • 2 replies
  • 534 views

Hello Rod,

In one of my simulation, I have losts to TEBs. After entering the text you need to press the Function Key (in this case F3). To do the shortcut, I am using the below script. This works amazing when its with just the click boxes.

Anyways, the issue that I am facing is, once I cross the slide that executes this JS, the TEB stops working. It does not allow me to enter any text further.

 

$(function(){
//Yes! use keydown 'cus some keys is fired only in this trigger,
//such arrows keys $("body").keydown(function(e){
//well you need keep on mind that your browser use some keys
//to call some function, so we'll prevent this e.preventDefault();

//now we caught the key code, yabadabadoo!!
var keyCode = e.keyCode || e.which;

//your keyCode contains the key code, F1 to F12
//is among 112 and 123. Just it. console.log(keyCode);
});
});

 

Please let me know if you know any fix for this issue.

 

    This topic has been closed for replies.

    2 replies

    Stagprime2687219
    Legend
    July 8, 2020

    Rod -

    I hope you don't mind me trying to help since you were requested specifically...

    RodWard
    Community Expert
    Community Expert
    July 9, 2020

    Go for it!  I have more than enough problems to solve.  All the merrier.

    varoonm981017
    Participant
    January 26, 2022

    Thankfully someones talking about this. I used the same code and facing the TEB issue. Cant type anything in the TEB. Is there a solution to this?

    Stagprime2687219
    Legend
    July 8, 2020

    Seems like maybe your TEB is losing focus.

    I know I had issues once with a TEB constantly losing focus so I had to force it.

     

    Also - is that all of your code - or is there more?

    From what you've shown, it looks like there is an extra set of   });  at the end.

    Or perhaps simply the commenting out of lines is leaving the active code in such a way that things break.

    SN020218Author
    Participating Frequently
    July 8, 2020

    Yeah thats all is the code.

    Even  I click on the TEB to get its focus back, it still doesnt type. I can attach the cptx file here to test.

    Stagprime2687219
    Legend
    July 8, 2020

    What if you try something like this...

    The question is - what do you want to have happen when the user presses F3?

    In the script shown below - we add the listener which calls the function each time a key is pressed.

    The Key Code for  F3  is 114 so we can then include an if statement within the function that is called each time a key is pressed such that if our variable equals 114 to go ahead and do something.

    This code assumes a TEB with the ID of  entryBox and a Captivate variable called key.

    This is placed in the on Enter action for the slide.