How can we detect/record whether a canvas element was written on?


I expect to include a canvas on my page in which the user would write on it with finger or stylus (for a mobile app). I would like to detect whether the user has written on the canvas during a 24-hour period, and increment that digit each time it is used in another 24-hour period. The purpose is to show a nearby message that congratulates the user for persistent practice on that particular canvas. (That’s different from counting the number of times the page was accessed, for example.)

Is this possible? I have no idea of how to detect whether a canvas element has been drawn on or not.


There are a bunch of methods listed here. My favourite is to use the toDataURL() function and compare it with another, blank canvas. If they are different, than the one you are comparing it to has something on it.