【问题标题】:Is it possible to get immediate neighbours of a key on keyboard?是否有可能在键盘上获得一个键的直接邻居?
【发布时间】:2018-02-25 21:23:29
【问题描述】:

例如,GR,T,Y,F,H,V,B 包围。但是,这对我的 keboard 来说是正确的。

是否可以动态获得这种“布局”?

【问题讨论】:

    标签: python keyboard keyboard-layout


    【解决方案1】:
    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]
    

    是否可以动态获得这种“布局”?

    抱歉,我的回复不是动态的 :) 但非常简单(注意,我正在使用 azerty 键盘,更改 qwert 的字母列表)

    祝你好运

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-11
    • 2022-12-05
    • 2012-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    相关资源
    最近更新 更多