python - upper() case of number key -
i'm trying implement input box in pygame. i've gotten point can input text in lower , upper case letters (shift changes upper case, usual). checking whether l_shift/r_shift pressed , if is, use char = char.upper()
turn char corresponds pressed key corresponding upper char. works fine letters (a-z -> a-z
). not work numbers , other special symbols 1 -> !
, 2 -> "
, . -> :
or , -> ;
(german keyboard layout).
is there better way in python turn chars corresponding shift+key chars?
there no inherent mapping numbers punctuation marks associated them on keyboard, you'll have specify them yourself. use map, this:
number_map = { '1':'!', '2':'@', '3':'#', #etc #etc } print(number_map['1']) # print !
this nice because can use other non-alphabetic keys.
Comments
Post a Comment