Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

TEB and Function Key JS code

New Here ,
Jul 08, 2020 Jul 08, 2020

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.

 

422
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 08, 2020 Jul 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 08, 2020 Jul 08, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 08, 2020 Jul 08, 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.

 

Stagprime_0-1594232259471.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 08, 2020 Jul 08, 2020

Rod -

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 08, 2020 Jul 08, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 26, 2022 Jan 26, 2022
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources