我在Ultron UN-1無線數字小鍵盤上鍵入5位數字。只有一些數字通過例如對於45465我可能會低於如何獲得Ultron UN-1無線數字小鍵盤與Psychopy一起使用?
'numlocknum_4numlockleftnumlocknum_5numlocknumlocknumlockleftnumlocknum_6numlockrightnumlocknumlockreturn'
我對PsychoPy v1.82.01輸入。我在Windows 8.1,64b上使用Asus TP300L。代碼如下。謝謝你的幫助。
if returnPressed == False:
while loopTest == True:
response = event.waitKeys(keyList = None)
userInput = userInput + response[0]
print ('response ', response)
if response[0] == 'return' or response[0] =='escape':
loopTest = False
returnPressed = True
JR,@jrgray,謝謝你的幫助。我嘗試了你的建議。它似乎仍然錯過了數字。下面是我輸入數字54645和45465時得到的結果。它不僅僅是刪除最後的數字。
( '用戶輸入', 'num_5num_4num_6return') ( '用戶輸入', 'num_4num_5num_6return')
while loopTest == True:
response = event.getKeys(keyList=['num_0', 'num_1', 'num_2', 'num_3', 'num_4', 'num_5', 'num_6', 'num_7', 'num_8', 'num_9', 'return', 'backspace', 'escape'])
if len(response) > 0:
userInput = userInput + response[0]
if response[0] == 'return' or response[0] =='escape':
loopTest = False
returnPressed = True
print ('user input ', userInput)
event.waitKeys()返回一個鍵列表。通常只有一個,並且正如上面所做的那樣訪問第零個元素是有意義的。但是可以返回多個響應,如果是這樣,您將無法訪問它們。值得在這裏檢查len(響應)。 –
Michael,謝謝你的回覆。我只在循環的每次迭代期間從waitKeys獲取一個密鑰。這些響應連接到userInput字段,這是我在上面顯示的「輸入」字段。鍵盤似乎會產生很多額外的字符和缺少一些的數字其實我在關鍵的。這是因爲如果他們正在沿途某處丟失。使用Microsoft Excel作爲輸入設備時,無線數字鍵盤正常工作。任何進一步的建議感激 –