$('#button').click(function (e) { if (e.clientX) { // physical click } else { // program click } });
From here.