In addition to what is mentioned in @triplepoint, look at the slider widget.
Here is an example on the matplotlib example page . This is a graphic slider, not a keyboard binding, but it is great for what you want to do.
Also note: to ensure that sliders and buttons remain responsive and not to collect garbage, object references ( amp_slider , freq_slider , etc.) must be supported by themselves.
(I create this community wiki as I simply copy the example from the example. This particular example teaches bad habits (for example, from pylab import * ), but it gets the point. The example has been fixed to avoid using pylab .)
from numpy import pi, sin import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Slider, Button, RadioButtons def signal(amp, freq): return amp * sin(2 * pi * freq * t) axis_color = 'lightgoldenrodyellow' fig = plt.figure() ax = fig.add_subplot(111)

Joe Kington Jul 14 '11 at 17:38 2011-07-14 17:38
source share