#!/usr/bin/env python3 # Show which key was pressed on the Braille display. import brlapi import errno #import Xlib.keysymdef.miscellany import time try: b = brlapi.Connection() b.setParameter(brlapi.PARAM_CLIENT_PRIORITY, 0, False, 100) b.enterTtyModeWithPath("") print("Server version " + str(b.getParameter(brlapi.PARAM_SERVER_VERSION, 0, brlapi.PARAMF_GLOBAL))) # print("Display size " + # str(b.getParameter(brlapi.PARAM_DISPLAY_SIZE, 0, brlapi.PARAMF_GLOBAL))) # for cmd in b.getParameter(brlapi.PARAM_BOUND_COMMAND_KEYCODES, 0, # brlapi.PARAMF_GLOBAL): # print(b.getParameter(brlapi.PARAM_COMMAND_KEYCODE_NAME, cmd, # brlapi.PARAMF_GLOBAL), cmd) tests = 5 b.writeText('enter key: ') for i in range(1,tests+1): k = b.readKey() keyCode = b.expandKeyCode(k) name = b.getParameter(brlapi.PARAM_COMMAND_KEYCODE_NAME, k, brlapi.PARAMF_GLOBAL) msg = 'test '+str(i)+ ' of '+ str(tests)+': '+ name b.writeText(msg) print('name ', name) print('key: ',k,' ',keyCode) time.sleep(3) b.leaveTtyMode() b.closeConnection() except Exception as e: print("error") print(e)