Forum Discussion
Tracking Keystrokes on Chromebook Tablet
Hello Heroes,
We have a module that simulates / forces multiselect functionality of an app using [ctrl] + [Mouse click]. We used Javascript to track the event, and it works perfectly on desktop, but it won't work on Chromebook Tablets. I tested the variable on stage to see if it even reads when I click the virtual keyboard on the tablet. No dice. Is there a way I can track tablet keystrokes utilizing Javascript?
Below is the Javascript we used...
var player = GetPlayer();
var wrapper = document.querySelector("#wrapper");
if (wrapper.addEventListener)
{
wrapper.addEventListener("mousedown", MouseDownHandler, false);
wrapper.addEventListener("mouseup", MouseUpHandler, false);
wrapper.addEventListener("DOMMouseDown", MouseDownHandler, false);
wrapper.addEventListener("DOMMouseUp", MouseUpHandler, false);
}
else
{
wrapper.attachEvent("onmousedown", MouseDownHandler);
wrapper.attachEvent("onmouseup", MouseUpHandler);
}
function MouseDownHandler(e)
{
var e = window.event || e;
if(e.ctrlKey==true){
console.log('CTRL pressed during click');
player.SetVar("isCTRLClicked",true);
}
return false;
}
function MouseUpHandler(e)
{
var e = window.event || e;
player.SetVar("isCTRLClicked",false);
return false;
}
Thank you,
Emanuel
- RussellKillips-Community Member
Hi Emanuel,
I don't think tablets/mobile devices respond to mouse events. Instead they use touch events.
- EmanuelFalade-6Community Member
Thank you Russell, I'll explore touch events and application.
- RussellKillips-Community Member
Hi Emanual,
Take a look at the attached story file. Perhaps this approach will work for you?
- EmanuelFalade-6Community Member
That didn't track on a Chromebook (w/ touchscreen). Thank you for putting that together, and sorry for the delay. It has been a crazy November.
I'll continue to hunt, but at least I know that touch should be the tracked event. That helps tremendously. I also will research findings specific to the devices we're using.