You should be able to use touch events. In many cases you can use the same functions that you wrote for the keypresses, or you can write them separately. Here's an example
var touchedElement = document.getElementById("myElementToBeTouched");
touchedElement.addEventListener("touchstart", funcTouchStart, false);
touchedElement.addEventListener("touchend", funcTouchEnd, false);
touchedElement.addEventListener("touchmove", funcTouchMove, false);
function funcTouchStart(e) {
//code to do what you want like set variables and check where on screen touch happened
var touches = e.changedTouches; //gets array of touch points, to get position
}
function funcTouchEnd(e) {
//code
}
function funcTouchMove(e) {
//code
}
To make them respond to left or right screen, you could use the touches[i].pageX that comes with these events and set the action to happen only if in the 25% of the screen from touches[i].pageX = 0 (for left) or last 25% to where the touches[i].pageX = width of screen/viewport.
This is not a complete working example but I hope its enough to give you an idea of what you could do. If you need more help with these events, try looking at one of MDN examples such as: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Touch_events