-1

For example G is surrounded with keys R,T,Y,F,H,V,B. However, this is true for my keboard.

Is it possible to get this kinda "layout" dynamically?

Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

1 Answers1

3
def get_keys_around(key):
    lines = 'azertyuiop', 'qsdfghjklm', 'wxcvbn'
    line_index, index = [(i, l.find(key)) for i, l in enumerate(lines) if key in l][0]
    lines = lines[line_index-1: line_index+2] if line_index else lines[0: 2]
    return [
        line[index + i] for line in lines for i in [-1, 0, 1]
        if len(line) > index + i and line[index + i] != key and index + i >= 0]

Is it possible to get this kinda "layout" dynamically?

Sorry my responds is not dynamic :) but very simple (notice, I'm working with an azerty keybord, change letters list for qwert)

good luck

lio
  • 49
  • 3
  • Ok, let's reformulate it. How to differentiate between qwerty, dvorak or azerty? =) – Pavel Voronin Feb 25 '18 at 22:20
  • 1
    I don't know if it's works but look there : https://stackoverflow.com/questions/42047253/how-to-detect-current-keyboard-language-in-python – lio Feb 25 '18 at 22:28