import board
import digitalio
import time
import usb_hid
import adafruit_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
keyboard = Keyboard(usb_hid.devices)
from digitalio import DigitalInOut, Direction, Pull
names = []
buttons = [board.GP13, board.GP12, board.GP11, board.GP10]
keys=[["keycode.SHIFT","keycode.A"],["","keycode.A"],["keycode.SHIFT","keycode.B"],["","keycode.B"]]
# Initializing Button
buttdata=[]
butt_state=[]
bt = (x for x in range(4))
for x in bt:
buttdata.append(digitalio.DigitalInOut(buttons[x]))
buttdata[x].direction = digitalio.Direction.INPUT
buttdata[x].pull = digitalio.Pull.UP
butt_state.append(buttdata[x].value)
while True:
bt = (x for x in range(4))
for x in bt:
cur_state = buttdata[x].value
if cur_state != butt_state[x]:
if not cur_state:
print(keys[x*2])
#print("Button " + str(x + 1) + " is off")
else:
print(keys[(x*2)+1])
#print("Button " + str(x + 1) + " is on")
butt_state[x] = cur_state
#while True:
# Check if button is pressed and if it is, to press the Macros and toggle LED
# if butt1.value:
# print("Button value is" & butt1.value)
# if butt1.value:
# if not butt1_on:
# butt1_on = True
# print("Button 1 is on")
# else:
# if butt1_on:
# butt1_on = False
# print("Button 1 is off")
# if butt2.value:
# print("Button 2 button Pressed")
# if butt3.value:
# print("Button 3 button Pressed")
# time.sleep(0.1)