<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle23
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Thanks! I don’t have a particularly deep motivation here, other than curiosity.<o:p></o:p></p>
<p class="MsoNormal">If you’re wondering how my curiosity got piqued initially, it was something like this:<o:p></o:p></p>
<p class="MsoNormal">A while ago, someone at work was adding copy/paste support to some component that didn’t have it.<o:p></o:p></p>
<p class="MsoNormal">I noticed that they “hardcoded” the shortcut “ctrl C”.<o:p></o:p></p>
<p class="MsoNormal">And I thought to myself:<o:p></o:p></p>
<p class="MsoNormal">Swing already “knows” that this is the right keyboard shortcut, in the sense that all components that support copy/paste “out of the box” use it.<o:p></o:p></p>
<p class="MsoNormal">It would be nice if there was some way to ASK it to tell me what it “knows”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Jeremy Wood <mickleness@gmail.com> <br>
<b>Sent:</b> Sunday, March 3, 2024 11:30 PM<br>
<b>To:</b> Yagnatinsky, Mark : Markets Pre Trade <mark.yagnatinsky@barclays.com>; client-libs-dev@openjdk.org<br>
<b>Subject:</b> Re[2]: how to get find out the keyboard shortcut for the paste action?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p><span style="font-size:12.0pt;font-family:"Helvetica",sans-serif;color:red">CAUTION: This email originated from outside our organisation -
<a href="mailto:mickleness@gmail.com">mickleness@gmail.com</a> Do not click on links, open attachments, or respond unless you recognize the sender and can validate the content is safe.</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">> But now I have a new question…<o:p></o:p></span></p>
</div>
<div id="x99354d8890154d97bd0da3f8ddf9a7af">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">> Is there any way to get the “usual” letter for a “common” operation?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Hmm. Good question. Not that I know of.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div id="xc650e78cbcd648f0917524dae88567a5">
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">> </span>Again, one could create a scratch text area and grovel through its input map, but that seems hacky.<span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div id="xdfaca6f86172442490e96b5554bfed4d">
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">I agree sifting through the L&F seems hacky.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">I don’t think I understand exactly what you’re trying to implement here. If you give me a more concrete example: maybe I (or someone on this list) can offer a more concrete
suggestion?<o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">I’ll add some context in case this speaks to your question.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">By default Swing gets this information in places like BasicTextUI#getInputMap(), which calls:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div id="x2b470291896542f49c92d4521e1b153b">
<pre>InputMap shared <span style="font-size:12.0pt;color:#080808">=<br> (</span>InputMap<span style="font-size:12.0pt;color:#080808">)</span>DefaultLookup<span style="font-size:12.0pt;color:#080808">.</span><i><span style="color:#080808">get</span></i><span style="font-size:12.0pt;color:#080808">(</span><span style="color:#871094">editor</span><span style="font-size:12.0pt;color:#080808">, </span><span style="color:#0033B3">this</span><span style="font-size:12.0pt;color:#080808">,<br> getPropertyPrefix() + </span><span style="color:#067D17">".focusInputMap</span><span style="font-size:12.0pt;color:#067D17">”</span><span style="font-size:12.0pt;color:#080808">);</span><o:p></o:p></pre>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">The following works on my Mac & Windows machine (I think using JDK 19), but I wouldn’t be surprised if it fails in other platforms / L&F’s. It feels brittle, but it might
(?) have potential:<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";color:#0033B3">private
</span><span style="font-size:10.0pt;font-family:"Courier New"">KeyStroke <span style="color:#00627A">
getCopyKeyStroke</span><span style="color:#080808">() {</span></span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p></o:p></span></p>
</div>
</div>
</div>
<div>
<div>
<pre><span style="color:#080808"> </span><span style="color:black">InputMap inputMap </span><span style="color:#080808">= (</span><span style="color:black">InputMap</span><span style="color:#080808">) </span><span style="color:black">UIManager</span><span style="color:#080808">.getDefaults().get(</span><span style="color:#067D17">"TextField.focusInputMap"</span><span style="color:#080808">);<br> </span><span style="color:#0033B3">for </span><span style="color:#080808">(</span><span style="color:black">KeyStroke keyStroke </span><span style="color:#080808">: </span><span style="color:black">inputMap</span><span style="color:#080808">.keys()) {<br> </span><span style="color:black">Object action </span><span style="color:#080808">= </span><span style="color:black">inputMap</span><span style="color:#080808">.get(</span><span style="color:black">keyStroke</span><span style="color:#080808">);<br> </span><span style="color:#0033B3">if </span><span style="color:#080808">(</span><span style="color:#067D17">"copy-to-clipboard"</span><span style="color:#080808">.equals(</span><span style="color:black">action</span><span style="color:#080808">)) {<br> </span><span style="color:#0033B3">return </span><span style="color:black">keyStroke</span><span style="color:#080808">;<br> }<br> }<br> </span><i><span style="color:#8C8C8C">// this will show all the default keystrokes<br>// System.out.println(Arrays.asList(inputMap.allKeys()));<br> <br> </span></i><span style="color:#0033B3">return null</span><span style="color:#080808">;<br>}<o:p></o:p></span></pre>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Regards,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"> - Jeremy<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">------ Original Message ------<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">From
<a href="mailto:mark.yagnatinsky@barclays.com">mark.yagnatinsky@barclays.com</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">To
<a href="mailto:mickleness@gmail.com">mickleness@gmail.com</a>; <a href="mailto:client-libs-dev@openjdk.org">
client-libs-dev@openjdk.org</a><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Date 3/3/24, 6:00:46 PM<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">Subject RE: how to get find out the keyboard shortcut for the paste action?<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div id="x900ea9d4889b43b">
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 8.0pt;margin-left:3.75pt;margin-top:2.25pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">Thanks for the response! I didn’t expect to get one at this point
<span style="font-family:Wingdings">J</span><o:p></o:p></p>
<p class="MsoNormal">It does indeed answer my question!<o:p></o:p></p>
<p class="MsoNormal">(Though you didn’t quite get the name right: there’s no Ex at the end…<o:p></o:p></p>
<p class="MsoNormal">I take it you’ve done some Windows programming at some point)<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">But now I have a new question…<o:p></o:p></p>
<p class="MsoNormal">Is there any way to get the “usual” letter for a “common” operation?<o:p></o:p></p>
<p class="MsoNormal">For instance, lots of programs support copy and paste.<o:p></o:p></p>
<p class="MsoNormal">Is there a way to ask Java “what is the standard letter for paste” and get back “V”?<o:p></o:p></p>
<p class="MsoNormal">Again, one could create a scratch text area and grovel through its input map, but that seems hacky.<o:p></o:p></p>
<p><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">This message is for information purposes only. It is not a recommendation, advice, offer or solicitation to buy or sell a product or service, nor an official confirmation of any transaction.
It is directed at persons who are professionals and is intended for the recipient(s) only. It is not directed at retail customers. This message is subject to the terms at:
<a href="https://clicktime.symantec.com/15t5z4mRR1xMFCVmtWvPc?h=_ZThFXzMRdPMMViuNihJVxTtPiys_I6w5KRtMVx1Fb4=&u=https://www.ib.barclays/disclosures/web-and-email-disclaimer.html">
https://www.ib.barclays/disclosures/web-and-email-disclaimer.html</a>. <o:p></o:p></span></p>
<p><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif">For important disclosures, please see:
<a href="https://clicktime.symantec.com/15t5uEa8xQGkqFfrLxXEz?h=aZV9E8QlHEZXtd0LrGSqdmqft6KqysFQSLGlZwqVa3M=&u=https://www.ib.barclays/disclosures/sales-and-trading-disclaimer.html">
https://www.ib.barclays/disclosures/sales-and-trading-disclaimer.html</a> regarding marketing commentary from Barclays Sales and/or Trading desks, who are active market participants;
<a href="https://clicktime.symantec.com/15t5ejzHaZDybRC5iHKo8?h=RfNE8pkWUQa8xg2DoVwTtgkk49rIoTtEUzNyxF83j9M=&u=https://www.ib.barclays/disclosures/barclays-global-markets-disclosures.html">
https://www.ib.barclays/disclosures/barclays-global-markets-disclosures.html</a> regarding our standard terms for Barclays Investment Bank where we trade with you in principal-to-principal wholesale markets transactions; and in respect to Barclays Research,
including disclosures relating to specific issuers, see: <a href="https://clicktime.symantec.com/15t5Zuo17wYPBUNAAiveW?h=-A3ytf21bzyvpw7G-HZH3xdk0z4TW9wQtXUIIHCyj8k=&u=http://publicresearch.barclays.com">
http://publicresearch.barclays.com</a>.<br>
__________________________________________________________________________________
<br>
If you are incorporated or operating in Australia, read these important disclosures:
<a href="https://clicktime.symantec.com/15t5jaBa3Aua1N21Fqiwk?h=LNM_ZzBtmQ4icORcCbaHc_8simHhFf5h1R4P9VgQL4g=&u=https://www.ib.barclays/disclosures/important-disclosures-asia-pacific.html">
https://www.ib.barclays/disclosures/important-disclosures-asia-pacific.html</a>.<br>
__________________________________________________________________________________<br>
For more details about how we use personal information, see our privacy notice: <a href="https://clicktime.symantec.com/15t5pQNrVnbARJqvoQ86N?h=zaTRORm7ul9DlmzrjTzMBw2RNalvZJOfCr_u6f-IlR0=&u=https://www.ib.barclays/disclosures/personal-information-use.html">
https://www.ib.barclays/disclosures/personal-information-use.html</a>. <br>
__________________________________________________________________________________<o:p></o:p></span></p>
</blockquote>
</div>
</div>
<P><SPAN lang=EN-US style="mso-ansi-language: EN-US">This message is for
information purposes only. It is not a recommendation, advice, offer or
solicitation to buy or sell a product or service, nor an official confirmation
of any transaction. It is directed at persons who are professionals and is
intended for the recipient(s) only. It is not directed at retail customers. This
message is subject to the terms at: <A
href="https://www.ib.barclays/disclosures/web-and-email-disclaimer.html">https://www.ib.barclays/disclosures/web-and-email-disclaimer.html</A>.
</SPAN></P>
<P><SPAN lang=EN-US style="mso-ansi-language: EN-US">For important disclosures,
please see: <A
href="https://www.ib.barclays/disclosures/sales-and-trading-disclaimer.html">https://www.ib.barclays/disclosures/sales-and-trading-disclaimer.html</A>
regarding marketing commentary from Barclays Sales and/or Trading desks, who are
active market participants; <A
href="https://www.ib.barclays/disclosures/barclays-global-markets-disclosures.html">https://www.ib.barclays/disclosures/barclays-global-markets-disclosures.html</A>
regarding our standard terms for Barclays Investment Bank where we trade with
you in principal-to-principal wholesale markets transactions; and in respect to
Barclays Research, including disclosures relating to specific issuers, see: <A
href="http://publicresearch.barclays.com">http://publicresearch.barclays.com</A>.<BR>__________________________________________________________________________________
<BR>If you are incorporated or operating in Australia, read these important
disclosures: <A
href="https://www.ib.barclays/disclosures/important-disclosures-asia-pacific.html">https://www.ib.barclays/disclosures/important-disclosures-asia-pacific.html</A>.<BR>__________________________________________________________________________________<BR>For
more details about how we use personal information, see our privacy notice: <A
href="https://www.ib.barclays/disclosures/personal-information-use.html">https://www.ib.barclays/disclosures/personal-information-use.html</A>.
<BR>__________________________________________________________________________________<BR></O:P></SPAN></P>
</body>
</html>