Quick search

Input recorder

New in version 1.1.0.


This part of Kivy is still experimental and this API is subject to change in a future version.

This is a class that can record and replay some input events. This can be used for test cases, screen savers etc.

Once activated, the recorder will listen for any input event and save its properties in a file with the delta time. Later, you can play the input file: it will generate fake touch events with the saved properties and dispatch it to the event loop.

By default, only the position is saved (‘pos’ profile and ‘sx’, ‘sy’, attributes). Change it only if you understand how input handling works.

Recording events

The best way is to use the “recorder” module. Check the Modules documentation to see how to activate a module.

Once activated, you can press F8 to start the recording. By default, events will be written to <currentpath>/recorder.kvi. When you want to stop recording, press F8 again.

You can replay the file by pressing F7.

Check the Recorder module module for more information.

Manual play

You can manually open a recorder file, and play it by doing:

from kivy.input.recorder import Recorder

rec = Recorder(filename='myrecorder.kvi') = True

If you want to loop over that file, you can do:

from kivy.input.recorder import Recorder

def recorder_loop(instance, value):
    if value is False: = True

rec = Recorder(filename='myrecorder.kvi')
rec.bind(play=recorder_loop) = True

Recording more attributes

You can extend the attributes to save on one condition: attributes values must be simple values, not instances of complex classes.

Let’s say you want to save the angle and pressure of the touch, if available:

from kivy.input.recorder import Recorder

rec = Recorder(filename='myrecorder.kvi',
    record_attrs=['is_touch', 'sx', 'sy', 'angle', 'pressure'],
    record_profile_mask=['pos', 'angle', 'pressure'])
rec.record = True

Or with modules variables:

$ python -m recorder,attrs=is_touch:sx:sy:angle:pressure,             profile_mask=pos:angle:pressure

Known limitations

  • Unable to save attributes with instances of complex classes.

  • Values that represent time will not be adjusted.

  • Can replay only complete records. If a begin/update/end event is missing, this could lead to ghost touches.

  • Stopping the replay before the end can lead to ghost touches.

class kivy.input.recorder.Recorder(**kwargs)[source]

Bases: kivy.event.EventDispatcher

Recorder class. Please check module documentation for more information.


Fired when the playing stops.

Changed in version 1.10.0: Event on_stop added.


Number of events recorded in the last session.

counter is a NumericProperty and defaults to 0, read-only.


Filename to save the output of the recorder.

filename is a StringProperty and defaults to ‘recorder.kvi’.


Boolean to start/stop the replay of the current file (if it exists).

play is a BooleanProperty and defaults to False.


Boolean to start/stop the recording of input events.

record is a BooleanProperty and defaults to False.


Attributes to record from the motion event.

record_attrs is a ListProperty and defaults to [‘is_touch’, ‘sx’, ‘sy’].


Profile to save in the fake motion event when replayed.

record_profile_mask is a ListProperty and defaults to [‘pos’].


Window instance to attach the recorder. If None, it will use the default instance.

window is a ObjectProperty and defaults to None.