set pKeyApproveString to "!#$%&'()*+,-./0123456789;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨ÆØ±Ž¥µðÝÞþŠªºýæø¿¡ƒ¼Ð«»… ÀÃÕŒœ­—“”‘’÷× "
set pNameMax to 31
else
set pKeyApproveString to "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_;"
set pNameMax to 8
end if
set pKeyApproveList to []
repeat with i = length(pKeyApproveString) down to 1
add(pKeyApproveList, charToNum(char i of pKeyApproveString))
end repeat
end
on keyDown me
if (the key = RETURN) or (the key = ENTER) then
handleDefaultKeyDown(script 1)
end if
set keyNum to charToNum(the key)
if not getOne(pKeyApproveList, keyNum) then
stopEvent()
else
if not ((the key = BACKSPACE) or length(the selection)) then
if length(field "fileName") >= pNameMax then
puppetSound(1, "fieldFull")
stopEvent()
else
puppetSound(1, "key" & random(3))
pass()
end if
else
if the key = BACKSPACE then
puppetSound(1, "deleteKey")
else
puppetSound(1, "key" & random(3))
end if
pass()
end if
end if
end
on keyUp me
set theLength to length(field "fileName")
if theLength >= pNameMax then
set the text of member "fileName" to char 1 to pNameMax of field "fileName"