问题
Is there a way in GWT to tell if the Shift key is down inside of an onClick() handler?
For example:
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
public class PanelTileBase implements ClickHandler {
PanelTileBase()
{
addClickHandler(this);
}
public void onClick(ClickEvent event)
{
// is the shift key down?
}
}
Thanks!
回答1:
How about this (untested)
void onClick(ClickEvent ev) {
NativeEvent nEv = ev.getNativeEvent();
if ( nEv.getShiftKey() ) {
// event is true.
}
}
回答2:
And for the keyboard API changed, but the idea is the same:
if (event.isShiftKeyDown()) {
// your code
}
回答3:
GWT KeyEvent API has the is{Alt,AnyModifier,Control,Meta,Shift}KeyDown() functions.
来源:https://stackoverflow.com/questions/1411752/shift-key-in-gwt