I have user keypress and keydown to get the current key pressed, but it won't work on touchscreen.
I figured that I need to use .on('input')
but how do I get that input?
In other words. I need this to work on a touchscreen:
$('#newtags').keypress(function(e){
if (e.which==13 || e.which==32 || e.which==188){
Do something
}
});
UPDATE: Thank you for you input. I have used the method where i check the input-fields last character, and remove the last character when function runs:
$('#newtags').on('keyup', function(e){
var valueofinput= $(this).val();
var lastcharofinput = valueofinput.substr(valueofinput.length - 1);
if (e.which==13 || e.which==32 || e.which==188 || e.which==190 || lastcharofinput==' ' || lastcharofinput==',' || lastcharofinput=='.'){
if (lastcharofinput==' ' || lastcharofinput==',' || lastcharofinput=='.'){
valueofinput = valueofinput.substr(0, valueofinput.length - 1);
}
}
});