<html><head>


<style type="text/css"><!--#x900ea9d4889b43b p.MsoNormal
{margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;}
#x900ea9d4889b43b div.WordSection1
{page: WordSection1;}
--></style><style id="css_styles" type="text/css"><!--blockquote.cite { margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc }
blockquote.cite2 {margin-left: 5px; margin-right: 0px; padding-left: 10px; padding-right:0px; border-left: 1px solid #cccccc; margin-top: 3px; padding-top: 0px; }
a img { border: 0px; }
table { border-collapse: collapse; }
li[style='text-align: center;'], li[style='text-align: center; '], li[style='text-align: right;'], li[style='text-align: right; '] {  list-style-position: inside;}
body { font-family: Helvetica; font-size: 9pt; }
.quote { margin-left: 1em; margin-right: 1em; border-left: 5px #ebebeb solid; padding-left: 0.3em; }
--></style>
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><span>> </span><span>But now I have a new question…</span></div><div id="x99354d8890154d97bd0da3f8ddf9a7af"><p class="MsoNormal" style="margin: 0px;"><o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal" style="margin: 0px;">> Is there any way to get the “usual” letter for a “common” operation?</p></div><div><br /></div><div>Hmm. Good question. Not that I know of.</div><div><br /></div><div><div id="xc650e78cbcd648f0917524dae88567a5"><div>> <span style="font-family:Calibri,sans-serif;font-size:14.666667px;">Again, one could create a scratch text area and grovel through its input map, but that seems hacky.</span></div><div><br /></div><div><div id="xdfaca6f86172442490e96b5554bfed4d"><div style="margin: 0px;">I agree sifting through the L&F seems hacky.</div><div style="margin: 0px;"><span><br /></span></div><div style="margin: 0px;"><span>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?</span></div></div></div><div></div><div><br /></div><div>I’ll add some context in case this speaks to your question.</div><div></div><div><br /></div><div>By default Swing gets this information in places like BasicTextUI#getInputMap(), which calls:</div><div><br /></div><div><div id="x2b470291896542f49c92d4521e1b153b"><pre style="margin-top: 0px; margin-bottom: 0px;"><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">InputMap shared </span><font color="#080808" face="JetBrains Mono, monospace" size="3">=<br />    (</font><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">InputMap</span><font color="#080808" face="JetBrains Mono, monospace" size="3">)</font><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">DefaultLookup</span><font color="#080808" face="JetBrains Mono, monospace" size="3">.</font><span style="color:#080808;font-family:'JetBrains Mono',monospace;font-size:9.8pt;font-style:italic;">get</span><font color="#080808" face="JetBrains Mono, monospace" size="3">(</font><span style="color:#871094;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">editor</span><font color="#080808" face="JetBrains Mono, monospace" size="3">, </font><span style="color:#0033B3;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">this</span><font color="#080808" face="JetBrains Mono, monospace" size="3">,<br />    getPropertyPrefix() + </font><span style="color:#067D17;font-family:'JetBrains Mono',monospace;font-size:9.8pt;">".focusInputMap</span><font color="#067d17" size="3">”</font><font color="#080808" face="JetBrains Mono, monospace" size="3">);</font></pre><pre style="margin-top: 0px; margin-bottom: 0px;"><font color="#080808" face="JetBrains Mono, monospace" size="3"></font></pre></div></div><div><br /></div><div>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:</div><div><br /></div><div><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt; color: rgb(0, 51, 179);">private </span><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">KeyStroke </span><span style="font-family: "JetBrains Mono", monospace; font-size: 9.8pt; color: rgb(0, 98, 122);">getCopyKeyStroke</span><span style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 9.8pt;">() {</span></div></div></div><div><div style="color: rgb(8, 8, 8); font-family: "JetBrains Mono", monospace; font-size: 9.8pt;"><pre>    <span style="color:#000000;">InputMap inputMap </span>= (<span style="color:#000000;">InputMap</span>) <span style="color:#000000;">UIManager</span>.getDefaults().get(<span style="color:#067d17;">"TextField.focusInputMap"</span>);<br />    <span style="color:#0033b3;">for </span>(<span style="color:#000000;">KeyStroke keyStroke </span>: <span style="color:#000000;">inputMap</span>.keys()) {<br />        <span style="color:#000000;">Object action </span>= <span style="color:#000000;">inputMap</span>.get(<span style="color:#000000;">keyStroke</span>);<br />        <span style="color:#0033b3;">if </span>(<span style="color:#067d17;">"copy-to-clipboard"</span>.equals(<span style="color:#000000;">action</span>)) {<br />            <span style="color:#0033b3;">return </span><span style="color:#000000;">keyStroke</span>;<br />        }<br />    }<br />    <span style="color:#8c8c8c;font-style:italic;">// this will show all the default keystrokes<br /></span><span style="color:#8c8c8c;font-style:italic;">//                System.out.println(Arrays.asList(inputMap.allKeys()));<br /></span><span style="color:#8c8c8c;font-style:italic;">    <br /></span><span style="color:#8c8c8c;font-style:italic;">    </span><span style="color:#0033b3;">return null</span>;<br />}</pre></div></div><div></div><div>Regards,</div><div> - Jeremy</div><div style="clear:both"><i><br /></i></div><div style="clear:both"><br /></div>
<div><br /></div>
<div>
<div>------ Original Message ------</div>
<div>From <a href="mailto:mark.yagnatinsky@barclays.com">mark.yagnatinsky@barclays.com</a></div>
<div>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></div>
<div>Date 3/3/24, 6:00:46 PM</div>
<div>Subject RE: how to get find out the keyboard shortcut for the paste action?</div></div><div><br /></div>
<div id="x900ea9d4889b43b" style="word-wrap:break-word"><blockquote cite="CH3PR12MB76199D23AB541CB4C09118AAF95C2@CH3PR12MB7619.namprd12.prod.outlook.com" type="cite" class="cite2">

<div class="WordSection1">
<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 xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal">It does indeed answer my question!<o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal">(Though you didn’t quite get the name right: there’s no Ex at the end…<o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal">I take it you’ve done some Windows programming at some point)<o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal"><o:p xmlns:o="#unknown"> </o:p></p>
<p class="MsoNormal">But now I have a new question…<o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal">Is there any way to get the “usual” letter for a “common” operation?<o:p xmlns:o="#unknown"></o:p></p>
<p class="MsoNormal">For instance, lots of programs support copy and paste.<o:p xmlns:o="#unknown"></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 xmlns:o="#unknown"></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 xmlns:o="#unknown"></o:p></p>
</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 /></span></p>
</blockquote></div>


</body></html>