<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'><font face="arial, helvetica, sans-serif"><span style="font-size: 12pt;">You can probably do it in a lot of languages. You can do it in Java by listening to KeyListener events. You get an event each time a particular key is depressed and released, in addition to a higher level event for a key "typed". </span></font><div style=""><span style="font-family: arial, helvetica, sans-serif;"><br></span></div><div style=""><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"></blockquote><span style="font-family: arial, helvetica, sans-serif;">from: https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html</span><br><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12.8px;">Type an uppercase 'A' by pressing the Shift and A keys.</span></div></blockquote><blockquote style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt; margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div><span style="font-family: Arial, Helvetica, sans-serif; font-size: 12.8px;">You'll see the following events, although perhaps not in this order: key-pressed (Shift), key-pressed (A), key typed ('A'), key-released (A), key-released (Shift). Note that Shift is listed as the modifier key for the key-typed and key-pressed events.</span></div></blockquote><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">You would need to keep track of your key-pressed and key-released events to see what the complete combination was. Maybe something like this pseudo-code:</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">List currentKeys = new List()</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">List comboKeys = new List()</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">while true()</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">{</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">  keyPressed(KeyEvent e) { </div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    currentKeys.add(e.getKeyChar());</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    comboKeys.add(e.getKeyChar());</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">  }</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">  keyReleased(Keyevent e) {</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    currentKeys.remove(e.getKeyChar())</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    if (currentKeys.size()==0) // end of sequence</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    {</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">      char c = comboMap.get(comboKeys.sort());</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">      if (c != null) </div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">        typeCharacterInEditor(c);</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">      comboKeys.removeAll();</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">    }</div><div style="color: rgb(0, 0, 0); font-family: arial, helvetica, sans-serif; font-size: 12pt;">}<br><div><br></div><div id="345c0c0d-4000-4b0c-b882-3bb9407949a1">Each time you depress a key it gets added to 2 lists. When you release it gets removed from the currently depressed list. Once all keys are released, you look at the list of all that were depressed during the current cycle and see if it matches one of your valid combinations. If so, you consider the matched character "typed". Either way you clear your second list for the next round.</div><div id="345c0c0d-4000-4b0c-b882-3bb9407949a1"><br></div><div id="345c0c0d-4000-4b0c-b882-3bb9407949a1"><span name="x"></span>--<br>Scott Plante <br>404-873-0058 x104<br><span name="x"></span><br></div><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Todor Fassl via Ale" <ale@ale.org><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org><br><b>Sent: </b>Tuesday, December 5, 2017 11:22:28 AM<br><b>Subject: </b>[ale] Slightly OT: Coding program to hit several keys at once<br><br>I want to write some code to simulate a braille keyboard. A braille <br>keyboard has 7 keys. One is the space bar. The other 6 you press at the <br>same time in different combinations. So, for example, on a braille <br>keyboard, to make the letter x, you press the 1, 3, 4, and 6 keys at <br>once. I want to simulate that by allowing the user to press the f, s, j, <br>and l keys at the same time. Does anybody know of a programming language <br>that handles something like that nicely? If you were going to recommend <br>a programming language to do that, what would it be?<br><br>My goal is to write a text editor that allows a user to type braille and <br>saves the output in BRF format. So the user hits the f, s, j, and l keys <br>at once and the editor puts a BRF character x into the buffer.<br><br>Right now, I'm leaning toward python because python has a gaming library <br>that seems to allow you to hit several keys at once. But maybe somebody <br>has done something like this in C or C++. I am about as sure as I can be <br>that perl won't work. I don't particularly care about the programming <br>language because by now I've learned so many different programming <br>languages in my life I figure I can learn another one in a few <br>days/weeks. I don't actually care if the code is portable to other <br>operating systems other than linux.  That might be nice but it's not <br>important.<br><br><br>-- <br>Todd<br>_______________________________________________<br>Ale mailing list<br>Ale@ale.org<br>http://mail.ale.org/mailman/listinfo/ale<br>See JOBS, ANNOUNCE and SCHOOLS lists at<br>http://mail.ale.org/mailman/listinfo<br></div><br></div></div></div></body></html>