[Keyboard] detect some special key in GP
Posted: Sep 20th, '17, 15:52
Hi, currently I am trying to create a small user interface wich should contain some text fields to input some text and I don't want to use the "ask" block.
A view weeks ago I've released a small project named "simple text writer / notepad" wich works very well, but I can not detect if the user want to type some punctuation marks like ",.-;:_+#*'".
The next problems are the multiple keyboard layouts, like the english and the german one.
GP doesn't recognizes if I press "y" so it outputs "z" (QUERTY and QUERTZ).
Okay if GP would recognize all keys on an QUERTY keyboard correctly, it would be aczeptable (for the beginning) but currently GP doesn't!
This is the main part of my "writer script" to detect the keys. I think the script should be okay, but when I press "F1" it outputs "p". if I press "5" on my nummpad it outputs "]", the key "END" outputs an "m".
What is wrong with moy script or the way how GP is detecting keys???
Please help!
A view weeks ago I've released a small project named "simple text writer / notepad" wich works very well, but I can not detect if the user want to type some punctuation marks like ",.-;:_+#*'".
The next problems are the multiple keyboard layouts, like the english and the german one.
GP doesn't recognizes if I press "y" so it outputs "z" (QUERTY and QUERTZ).
Okay if GP would recognize all keys on an QUERTY keyboard correctly, it would be aczeptable (for the beginning) but currently GP doesn't!
Code: Select all
whenKeyPressed 'any' 'key'
self_setStageColor (colorHSV ((at (codePoints key) 1) / 4) 1 1)
self_say key
if ((containsSubString key 'arrow' 1) == 0) {
if (key == 'space') {
setShared 'text' (join (shared 'text') ' ')
} (key == 'enter') {
setShared 'text' (join (shared 'text') (newline))
} (key == 'tab') {
setShared 'text' (join (shared 'text') ' ')
} (key == 'delete') {
setShared 'text' (joinStrings (copyFromTo (letters (shared 'text')) 1 ((count (letters (shared 'text'))) - 1)))
} (and (contains (range 1 9) (toNumber key)) (keyIsDown 'shift')) {
setShared 'text' (join (shared 'text') (string ((at (codePoints key) 1) - 16)))
} else {
if (keyIsDown 'shift') {
setShared 'text' (join (shared 'text') (toUpperCase key))
} else {
setShared 'text' (join (shared 'text') key)
}
}
}
}
What is wrong with moy script or the way how GP is detecting keys???
Please help!