Here you can find the source of keyStrokeToString(final KeyStroke keyStroke)
Parameter | Description |
---|---|
keyStroke | key stroke whose nice string representation to return |
public static String keyStrokeToString(final KeyStroke keyStroke)
//package com.java2s; //License from project: Apache License import java.awt.event.KeyEvent; import javax.swing.KeyStroke; public class Main { /**/*www . j a v a2 s . c o m*/ * Returns a nice string representation of the specified key stroke. * <p> * For example returns <code>" (Ctrl+P)"</code> for the keystroke of CTRL+P. * </p> * * @param keyStroke key stroke whose nice string representation to return * @return a nice string representation of the specified key stroke */ public static String keyStrokeToString(final KeyStroke keyStroke) { final StringBuilder sb = new StringBuilder(" ("); if (keyStroke.getModifiers() != 0) sb.append( KeyEvent.getKeyModifiersText(keyStroke.getModifiers())) .append('+'); sb.append(KeyEvent.getKeyText(keyStroke.getKeyCode())).append(')'); return sb.toString(); } }