'How do I delete the keyboard.on_press listener in Python?

If I have a code like this:

import keyboard

press = keyboard.on_press(lambda key : SOMETHING)

Is there something like press.close() that I can do to delete the listener? Does del press work?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source