当前位置: 首页>>代码示例>>Python>>正文


Python keyboard.Keyboard类代码示例

本文整理汇总了Python中keyboard.Keyboard的典型用法代码示例。如果您正苦于以下问题:Python Keyboard类的具体用法?Python Keyboard怎么用?Python Keyboard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Keyboard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_key_prox_keys

 def test_key_prox_keys(self):
     kb = Keyboard('US')
     for inp, res in [('a', 'aqwsxz'),
                      ('t', 'tr456yhgf'),
                      (';', ";lop['/.")]:
         ret = kb.keyboard_prox_key(inp)
         assert set(ret) == set(res)
开发者ID:rchatterjee,项目名称:mistypography,代码行数:7,代码来源:test_keyboard.py

示例2: test_part_key_presses

 def test_part_key_presses(self, inp, res):
     res = res.format(**key)
     kb = Keyboard('US')
     i = random.randint(0, len(res))
     pre_word, shift, caps = kb.part_key_press_string(res[:i])
     post_word, shift, caps = kb.part_key_press_string(res[i:], shift, caps)
     assert inp == pre_word + post_word
开发者ID:rchatterjee,项目名称:mistypography,代码行数:7,代码来源:test_keyboard.py

示例3: dispense_and_scan

 def dispense_and_scan(self, author_selection):
     j = 0
     #f = open(self.dispenserDevices[0], "wb")
     f = open("/dev/ttyUSB0", "wb")
     f.write("020180000380".decode("hex"))
     f.flush()
     f.close()
     #k = Keyboard(self.scannerKeyDev[0])
     k = Keyboard("/dev/input/event0")
     k.flush()
     code = ""
     i = 0
     #return code
     start_time = time.time()
     while i < 8:
         key = k.readKey()
         #print key
         if key is not None:
             code += key
             i += 1
         end_time = time.time() - start_time 
         #self.write_log("end time = "+str(end_time))
         if(end_time > 4):
             self.write_log("reader time out!!")
             break;
     self.write_log("Dispensing from card dispenser " + str(0))
     self.write_log("device = "+str(self.dispenserDevices[0]))
     self.write_log("scanner device = "+str(self.scannerKeyDev[0]))
     return code
开发者ID:pierrep,项目名称:dialastory,代码行数:29,代码来源:puffin_sm.py

示例4: test_word_to_key_press

 def test_word_to_key_press(self, inp, res):
     key = {'c': CAPS_KEY,
            's': SHIFT_KEY}
     KB = Keyboard('US')
     t1 = KB.word_to_key_presses(inp)
     t2 = res.format(**key)
     assert t1 == t2, "{!r} <--> {!r}".format(t1, t2)
开发者ID:rchatterjee,项目名称:mistypography,代码行数:7,代码来源:test_keyboard.py

示例5: test_other_key_presses_to_word

 def test_other_key_presses_to_word(self, inp, res):
     key = {'c': CAPS_KEY,
            's': SHIFT_KEY}
     KB = Keyboard('US')
     kw = KB.key_presses_to_word('{c}asdf{s}1{c}sdf'.format(**key))
     assert 'ASDFasdf' == KB.key_presses_to_word('{c}asdf{s}a{c}sdf'.format(**key))
     assert 'ASDF!sdf' == KB.key_presses_to_word('{c}asdf{s}1{c}sdf'.format(**key))
     assert KB.key_presses_to_word('{s}apa'.format(**key)) == 'Apa'
开发者ID:rchatterjee,项目名称:mistypography,代码行数:8,代码来源:test_keyboard.py

示例6: setup_network_connection

    def setup_network_connection(self):
        Keyboard.show(layout=[])

        from subprocess import Popen
        if self.wicd is not None:
            if self.wicd.poll() is None:
                return
        self.wicd = Popen(['xterm', '-maximized', '-e', 'wicd-curses'])
开发者ID:stdk,项目名称:stoppark_panel,代码行数:8,代码来源:config_ui.py

示例7: test_loc

 def test_loc(self):
     inp_res_map = [(('t'), (1,5,0)),
                   (('T'), (1,5,1)),
                   (('a'), (2,1,0)),
                   (('('), (0,9,1)),
                   (('M'), (3,7,1))]
     kb = Keyboard('US')
     for q, r in inp_res_map:
         assert kb.loc(*q) == r
开发者ID:rchatterjee,项目名称:mistypography,代码行数:9,代码来源:test_keyboard.py

示例8: volume_down

 def volume_down():
     """
     Decrease system volume
     Done by triggering a fake VK_VOLUME_DOWN key event
     :return: void
     """
     Sound.__track()
     Sound.__set_current_volume(Sound.current_volume() - 2)
     Keyboard.key(Keyboard.VK_VOLUME_DOWN)
开发者ID:Paradoxis,项目名称:Windows-Sound-Manager,代码行数:9,代码来源:sound.py

示例9: volume_up

 def volume_up():
     """
     Increase system volume
     Done by triggering a fake VK_VOLUME_UP key event
     :return: void
     """
     Sound.__track()
     Sound.__set_current_volume(Sound.current_volume() + 2)
     Keyboard.key(Keyboard.VK_VOLUME_UP)
开发者ID:Paradoxis,项目名称:Windows-Sound-Manager,代码行数:9,代码来源:sound.py

示例10: mute

 def mute():
     """
     Mute or un-mute the system sounds
     Done by triggering a fake VK_VOLUME_MUTE key event
     :return: void
     """
     Sound.__track()
     Sound.__is_muted = (not Sound.__is_muted)
     Keyboard.key(Keyboard.VK_VOLUME_MUTE)
开发者ID:Paradoxis,项目名称:Windows-Sound-Manager,代码行数:9,代码来源:sound.py

示例11: test_sub_word_table

 def test_sub_word_table(self, inp, res):
     kb = Keyboard('US')
     res = res.format(**key)
     A = kb.sub_word_table(res)
     print '\n'.join(str(x) for x in A)
     for i in xrange(len(res)):
         pre_w, shift, caps = A[i][0]
         post_w = A[i][2*shift + caps + 1][0]
         assert pre_w + post_w == inp
开发者ID:rchatterjee,项目名称:mistypography,代码行数:9,代码来源:test_keyboard.py

示例12: test_keyboard_dist

 def test_keyboard_dist(self):
     inp_res_map = [(('t', 't'), (0)),
                    (('t', 'T'), (0.8)),
                    (('a', 'S'), (1.8)),
                    (('a', 'w'), (2)),
                    (('w', '$'), (3.8)),
                    (('<', '>'), (1))
                ]
     kb = Keyboard('US')
     for q, r in inp_res_map:
         assert kb.keyboard_dist(*q) == r
开发者ID:rchatterjee,项目名称:mistypography,代码行数:11,代码来源:test_keyboard.py

示例13: test_key_press_insert_edits

 def test_key_press_insert_edits(self, inp, res):
     inp_res_map = [(('{s}pa'.format(**key), [CAPS_KEY, SHIFT_KEY, 'a'], [CAPS_KEY, 't']),
                     ('pA', 'Pa', 'aPa', 'pa', 'PA', 'tpa', # j=0
                      'pA', 'Pa', 'Apa', 'A', 'a', 'Ta',   # j=1
                      'PA', 'PA', 'Paa', 'P', 'P', 'Pt',   # j=2
                      'Paa'))
     ]
     kb = Keyboard('US')
     for inp, res in inp_res_map:
         for i,r in enumerate(kb.key_press_insert_edits(*inp)):
             print i,r,res[i]
             assert r == res[i]
开发者ID:rchatterjee,项目名称:mistypography,代码行数:12,代码来源:test_keyboard.py

示例14: __init__

class Gui:
    def __init__(self, navdb):
        splash.show()
        self.keyb = Keyboard()                                # processes input from keyboard & mouse
        self.scr  = Screen()                                  # screen output object

    def update(self, sim):
        self.keyb.update(sim, sim.stack, self.scr, sim.traf)  # Check for keys & mouse
        self.scr.update(sim, sim.traf)                        # GUI update

    def reset(self):
        self.scr.objdel()                                     # Delete user defined objects

    def close(self):
        pg.quit()
开发者ID:AlexanderFSX,项目名称:bluesky,代码行数:15,代码来源:gui.py

示例15: main

def main():
    win = Window(fullscreen=True, visible=False)
    camera = Camera(win.width, win.height, (0, 0), 100)
    renderer = Renderer()
    maze = Maze()
    maze.create(50, 30, 300)
    keyboard = Keyboard()
    keyboard.key_handlers[key.ESCAPE] = win.close
    keyboard.key_handlers.update(camera.key_handlers)
    clock.schedule(maze.update)
    win.on_draw = lambda: renderer.on_draw(maze, camera, win.width, win.height)
    win.on_key_press = keyboard.on_key_press
    keyboard.print_handlers()
    win.set_visible()
    app.run()
开发者ID:msarch,项目名称:py,代码行数:15,代码来源:run.py


注:本文中的keyboard.Keyboard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。