how to create a modal operator.

I want to create a operator that run in “background”, similar to screencast_keys that allow other operators to run, but I not understand how to do it.

the idea is the operator read mouse speed and change a brush strength to simulate pressure sensitivity.

In the templates, you have the operator_modal_timer.py that you can inspire you for what you want to do I think.