Commits

Anonymous committed 840fe97

get_all_keys_in_layout can now return all positions up to a max_layer.

  • Participants
  • Parent commits 08b1667
  • Branches numpy

Comments (0)

Files changed (1)

     return positions
 
 
-def get_all_keys_in_layout(layout):
+def get_all_keys_in_layout(layout, max_layer=0):
     """Get all keys which are in the layout. Sorted the same way as the positions from get_all_positions_in_layout(). 
 
     >>> get_all_keys_in_layout(TEST_LAYOUT)
+    ['^', '⇥', 'u', '\\n', ' ', '⇙']
+    >>> get_all_keys_in_layout(TEST_LAYOUT, max_layer=5)
     ['^', 'ˇ', '↻', '⇥', 'u', 'U', '\\\\', '⇱', '⊂', '\\n', ' ', '⇙']
     """
     keys = []
     for line in layout[:5]:
         for key in line:
-            for letter in key:
+            for letter in key[:max_layer+1]:
                 if letter: 
                     keys.append(letter)
     return keys