Keyboard interface that is returned by
WindowBase.request_keyboard(). When you request a keyboard,
you’ll get an instance of this class. Whatever the keyboard input is
(system or virtual keyboard), you’ll receive events through this
instance.

Events :

on_key_down: keycode, text, modifiers

Fired when a new key is pressed down

on_key_up: keycode

Fired when a key is released (up)

Here is an example of how to request a Keyboard in accordance with the
current configuration:

importkivykivy.require('1.0.8')fromkivy.core.windowimportWindowfromkivy.uix.widgetimportWidgetclassMyKeyboardListener(Widget):def__init__(self,**kwargs):super(MyKeyboardListener,self).__init__(**kwargs)self._keyboard=Window.request_keyboard(self._keyboard_closed,self,'text')ifself._keyboard.widget:# If it exists, this widget is a VKeyboard object which you can use# to change the keyboard layout.passself._keyboard.bind(on_key_down=self._on_keyboard_down)def_keyboard_closed(self):print('My keyboard have been closed!')self._keyboard.unbind(on_key_down=self._on_keyboard_down)self._keyboard=Nonedef_on_keyboard_down(self,keyboard,keycode,text,modifiers):print('The key',keycode,'have been pressed')print(' - text is %r'%text)print(' - modifiers are %r'%modifiers)# Keycode is composed of an integer + a string# If we hit escape, release the keyboardifkeycode[1]=='escape':keyboard.release()# Return True to accept the key. Otherwise, it will be used by# the system.returnTrueif__name__=='__main__':fromkivy.baseimportrunTouchApprunTouchApp(MyKeyboardListener())

Fired when the event loop wants to close the window, or if the
escape key is pressed and exit_on_escape is True. If a function
bound to this event returns True, the window will not be closed.
If the the event is triggered because of the keyboard escape key,
the keyword argument source is dispatched along with a value of
keyboard to the bound functions.

New in version 1.9.0.

on_keyboard: key, scancode, codepoint, modifier

Fired when the keyboard is used for input.

Changed in version 1.3.0: The unicode parameter has been deprecated in favor of
codepoint, and will be removed completely in future versions.

on_key_down: key, scancode, codepoint

Fired when a key pressed.

Changed in version 1.3.0: The unicode parameter has been deprecated in favor of
codepoint, and will be removed completely in future versions.

on_key_up: key, scancode, codepoint

Fired when a key is released.

Changed in version 1.3.0: The unicode parameter has be deprecated in favor of
codepoint, and will be removed completely in future versions.

on_dropfile: str

Fired when a file is dropped on the application.

on_memorywarning:

Fired when the platform have memory issue (iOS / Android mostly)
You can listen to this one, and clean whatever you can.

Event called before we close the window. If a bound function returns
True, the window will not be closed. If the the event is triggered
because of the keyboard escape key, the keyword argument source is
dispatched along with a value of keyboard to the bound functions.

Warning

When the bound function returns True the window will not be closed,
so use with care because the user would not be able to close the
program, even if the red X is clicked.

Event called whem text: i.e. alpha numeric non control keys or set
of keys is entered. As it is not gaurenteed whether we get one
character or multiple ones, this event supports handling multiple
characters.

Internal widget method to request the keyboard. This method is rarely
required by the end-user as it is handled automatically by the
TextInput. We expose it in case you want
to handle the keyboard manually for unique input scenarios.

A widget can request the keyboard, indicating a callback to call
when the keyboard is released (or taken by another widget).

Parameters :

callback: func

Callback that will be called when the keyboard is
closed. This can be because somebody else requested the
keyboard or the user closed it.

target: Widget

Attach the keyboard to the specified target. This should be
the widget that requested the keyboard. Ensure you have a
different target attached to each keyboard if you’re working in
a multi user mode.

New in version 1.0.8.

input_type: string

Choose the type of soft keyboard to request. Can be one of
‘text’, ‘number’, ‘url’, ‘mail’, ‘datetime’, ‘tel’, ‘address’.

Note

input_type is currently only honored on mobile devices.

New in version 1.8.0.

Return :

An instance of Keyboard containing the callback, target,
and if the configuration allows it, a
VKeyboard instance attached as a
.widget property.

Note

The behavior of this function is heavily influenced by the current
keyboard_mode. Please see the Config’s
configuration tokens section for
more information.