From: Ismaƫl Bouya Date: Sat, 25 Jun 2016 23:20:37 +0000 (+0200) Subject: Add exit key X-Git-Tag: 1.0.0~77 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FPython%2FMusicSampler.git;a=commitdiff_plain;h=b68b4e8fd7e0769e6c33f68f6b6d9db190a41b54 Add exit key --- diff --git a/helpers/mapping.py b/helpers/mapping.py index 4a1cd98..66d860d 100644 --- a/helpers/mapping.py +++ b/helpers/mapping.py @@ -5,6 +5,7 @@ from kivy.core.window import Window import threading import pygame import yaml +import sys from .lock import * from .music_file import * @@ -29,8 +30,16 @@ class Mapping(RelativeLayout): def _on_keyboard_down(self, keyboard, keycode, text, modifiers): key = self.find_by_key_code(keycode) - if key is not None: + if len(modifiers) == 0 and key is not None: threading.Thread(name = "MSKeyAction", target=key.do_actions).start() + elif 'ctrl' in modifiers and (keycode[0] == 113 or keycode[0] == '99'): + for thread in threading.enumerate(): + if thread.getName()[0:2] != "MS": + continue + thread.join() + + pygame.quit() + sys.exit() return True def find_by_key_code(self, key_code):