Move keys to constants
[naja.git] / naja / widgets / selector.py
index 49cf8d8715048a8371d943c605b112944a6d4371..c5ba07f37a4eb490010155d5b334f0e82c26ed14 100644 (file)
@@ -1,5 +1,6 @@
 import pygame.locals as pgl
 
+from naja.constants import KEYS
 from naja.widgets.base import Container
 from naja.resources import resources
 from naja.resources.mutators import EIGHT_BIT, R270
@@ -22,15 +23,14 @@ class SelectorWidget(Container):
 
     def handle_event(self, ev):
         if ev.type == pgl.KEYDOWN:
-            if ev.key in (pgl.K_DOWN, pgl.K_s, pgl.K_o,
-                          pgl.K_UP, pgl.K_w, pgl.K_COMMA):
-                if ev.key in (pgl.K_DOWN, pgl.K_s, pgl.K_o):
+            if ev.key in KEYS.UP + KEYS.DOWN:
+                if ev.key in KEYS.DOWN:
                     self.position += 1
                 else:
                     self.position -= 1
                 self.position %= len(self.widgets)
                 return True
-            elif ev.key in (pgl.K_RETURN, pgl.K_KP_ENTER):
+            elif ev.key in KEYS.SELECT:
                 return self.widgets[self.position].callback('click')
 
         return super(SelectorWidget, self).handle_event(ev)