there's not a lot of documentation for this but I'm hoping someone can help me.
I'm using the QRTEngine provided by the folks over at http://qrtengine.com/ for Qualtrics (http://www.qualtrics.com/) - a survey tool.
I have managed to set up a 'agree/disagree' survey quite easily (user presses the key 'z' for disagree and 'm' for agree)
The problem is that I need this to work on mobile too. Now I've tried the following:
var j = jQuery.noConflict();
(function( j ) {
j(function() {
// More code using $ as alias to jQuery
var e = j.Event("keyup");
e.which = 77; // # Some key code value
j( ".agree" ).bind( "click", function( event ) {
j(this).trigger(e);
alert(e.which);
});
});
})(j);
Which executes the alert but doesn't seem to simulate the keypress. I don't think there's anything wrong with my code, but I'm wondering if I'm missing something in regard to the QRTEngine I'm using.
Any help (ANY) would be appreciated.
Thanks
$ is the alias for the Prototype framework in Qualtrics. If you want use an alias for jQuery you need to make it something else like $j:
var $j = jQuery.noConflict();
EDIT: Maybe this is your problem...from http://bililite.com/blog/2015/01/14/rethinking-fn-sendkeys/ :
"Modern browsers won't let synthetic events (triggered with dispatchEvent) execute their default actions (meaning the action that would occur if the event was triggered by a user action). The Event object has a read-only field called isTrusted that is false for anything but unmodified user-initiated events. These are called "trusted events", and I understand the justification, but they go too far. It makes it impossible to implement a virtual keyboard, since triggering keydown or keypress events aren't trusted and won't insert the character (the default action)."
Check out the link referenced above for a potential solution.