DTM keypress question



Hi people, new to DTM.

I am trying to setup a keypress condition which only fires if keyCode is X. How do I setup the rule properly for the keyCode check?

Accepted Solutions (1)

Accepted Solutions (1)



Alright, I managed to "hack" it up so it works.

Summary of issues:

1) Expose KeyDown as rule condition

2) In the script, when defining the condition function, DTM should pass the same variable that is passed through to the ruleMatch function.


            var h = b.find(o, function(e) {
                try {
                    return !e.call(i, n, u)...

e is the condition function which is called with 3 variables. But on init, the condition is only declared as a simple function()

            conditions: [function() {

It should take in 3 variables too so that custom rule condition can make use of the 3 variables for customized tracking.

The below is what I used in the pageload rule to run a custom "hack" for my rule. My event rule is I want to track left arrow key press when a pop up is in the dom (media gallery scenario)

_satellite.registerEvents($("body")[0], ["keydown"])

_satellite.rules[0].conditions[0] = function(i, n, u){console.log(i); return $("popup").length>0&&37===i.keyCode;};

_satellite.rules[0].event = "keydown"