Quick search

Table Of Contents

Input management

Our input system is wide and simple at the same time. We are currently able to natively support :

  • Windows multitouch events (pencil and finger)
  • OS X touchpads
  • Linux multitouch events (kernel and mtdev)
  • Linux wacom drivers (pencil and finger)
  • TUIO

All the input management is configurable in the Kivy config. You can easily use many multitouch devices in one Kivy application.

When the events have been read from the devices, they are dispatched through a post processing module before being sent to your application. We also have several default modules for :

  • Double tap detection
  • Decreasing jittering
  • Decreasing the inaccuracy of touch on “bad” DIY hardware
  • Ignoring regions
class kivy.input.MotionEvent(device, id, args)[ソース]

ベースクラス: kivy.input.motionevent.MotionEvent

Abstract class that represents an input event (touch or non-touch).

id: str

unique ID of the MotionEvent

args: list

list of parameters, passed to the depack() function


Apply a transformation on x, y, z, px, py, pz, ox, oy, oz, dx, dy, dz


Copy some attribute to another touch object.


Depack args into attributes of the class


Return the distance between the current touch and another touch.


Return delta between last position and current position, in the screen coordinate system (self.dx, self.dy)

grab(class_instance, exclusive=False)[ソース]

Grab this motion event. You can grab a touch if you want to receive subsequent on_touch_move() and on_touch_up() events, even if the touch is not dispatched by the parent:

def on_touch_down(self, touch):

def on_touch_move(self, touch):
    if touch.grab_current is self:
        # I received my grabbed touch
        # it's a normal touch

def on_touch_up(self, touch):
    if touch.grab_current is self:
        # I receive my grabbed touch, I must ungrab it!
        # it's a normal touch

Returns True if the touch is a mousewheel scrolling

バージョン 1.6.0 で追加.


Move the touch to another position


Return the initial position of the touch in the screen coordinate system (self.ox, self.oy)


Pop attributes values from the stack


Return the previous position of the touch in the screen coordinate system (self.px, self.py)


Push attribute values in attrs onto the stack

scale_for_screen(w, h, p=None, rotation=0, smode='None', kheight=0)[ソース]

Scale position for the screen


Return the position in the 0-1 coordinate system (self.sx, self.sy)


Ungrab a previously grabbed touch

class kivy.input.MotionEventProvider(device, args)[ソース]

ベースクラス: builtins.object

Base class for a provider.


Start the provider. This method is automatically called when the application is started and if the configuration uses the current provider.


Stop the provider.


Update the provider and dispatch all the new touch events though the dispatch_fn argument.

class kivy.input.MotionEventFactory[ソース]

ベースクラス: builtins.object

MotionEvent factory is a class that registers all availables input factories. If you create a new input factory, you need to register it here:

MotionEventFactory.register('myproviderid', MyInputProvider)
static get(name)[ソース]

Get a provider class from the provider id

static list()[ソース]

Get a list of all available providers

static register(name, classname)[ソース]

Register a input provider in the database