Controling my GUI with just two keys..(for disable people)
1 view (last 30 days)
Show older comments
Hi friends , I would like to create a GUI in order to communicate with my friend . He can only move two fingers . I would like to display the letter he wants on the screen after he hits the first key a number of times. Possibly using the other key to erase the letters. How can I display different letters just with one click?. Thank you for the suggestions.
0 Comments
Answers (4)
John D'Errico
on 28 Aug 2015
Edited: John D'Errico
on 28 Aug 2015
Well, the simple answer is Morse code! Use the time between clicks to indicate dot versus dash. Of course, that requires him to learn Morse code, but that should be doable. Or, use the two keys to differentiate between dot versus dash, but that removes the ability to have an undo key.
0 Comments
Walter Roberson
on 28 Aug 2015
Think of how people typically entered their names in High Score tables of video games: cursor right moves a selector to the next character possibility, and Enter chooses the one currently being shown.
0 Comments
Joseph Cheng
on 2 Sep 2015
I'm not familiar with the original software that Stephen Hawking used but a simple solution is a function that looks at the time since last key pressed. Here is an example i threw together which you can adapt to change incrementing numbers (right arrow key) and reset (left arrow key) for letters. A hint is to use the dtime if statement to perform text position increment, letter increment, or if you want to get fancy and not have the person hit the key 26 times to get to z is to have keypress stages.
Such as if we take a trip back a few years before touch screen cellphones and diminishing landlines, the letters are entered through a two stage process. The first stage of key presses is to select a triplet of letters abc, def, ghi, etc. then subsequent would loop through the set of 3 and pausing before the next key press would lock that letter in.
function twokeypress()
tic,
hfig = figure(1);
htext = uicontrol('style','edit','string','0','unit','normalized','position',[.4 .5 .2 .1])
set(hfig,'keypressfcn',{@pressedkey,htext})
tpressed = toc;
set(hfig,'userdata',[1;tpressed])
function pressedkey(hobject,event,htext)
tpressed = toc;
userdata=get(hobject,'userdata');
ind = userdata(1);
dtime = tpressed - userdata(2);
number= str2num(get(htext,'string'));
switch event.Key
case 'rightarrow'
if dtime<1
set(htext,'string',num2str(number+1));
elseif dtime>=1
set(htext,'string',num2str(number+10));
end
case 'leftarrow'
set(htext,'string',num2str(0));
end
tpressed = toc;
set(hobject,'userdata',[ind;tpressed])
1 Comment
Joseph Cheng
on 2 Sep 2015
Ignore the ind and userdata(1) portions of the code. It was left over when I implemented the letter selection code. ind was the index position of a string of possible letters.
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!