rende
rende

Reputation: 31

How to get pen pressure data from the samsung galaxy note pro stylus inside chrome?

Basicly in javascript in my html I want to be able to do something like this.

var penpressure = inputDevice.getPressure();
console.log(penpressure);

Ideally this would work for other kinds of pressure inputs as well, wacom on desktop machines (without a plugin) just from the normal driver. Different tablets with stylus pens etc..

Upvotes: 1

Views: 1184

Answers (1)

joseluismurillorios
joseluismurillorios

Reputation: 1014

const HAS_POINTER = ('onpointermove' in window);
window.addEventListener(HAS_POINTER ? 'pointermove' : 'mousemove', (e) => {
  const pressure = HAS_POINTER ? e.pressure : 1;
  context.lineWidth = pressure * YOUR_STROKE_SIZE;
  draw();
}

Pressure max is 1

Upvotes: 0

Related Questions