本文整理了Java中org.lwjgl.input.Keyboard.getEventKeyState()
方法的一些代码示例,展示了Keyboard.getEventKeyState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Keyboard.getEventKeyState()
方法的具体详情如下:
包路径:org.lwjgl.input.Keyboard
类名称:Keyboard
方法名:getEventKeyState
暂无
代码示例来源:origin: MovingBlocks/Terasology
@Override
public Queue<KeyboardAction> getInputQueue() {
Queue<KeyboardAction> result = Queues.newArrayDeque();
while (Keyboard.next()) {
ButtonState state;
if (Keyboard.isRepeatEvent()) {
state = ButtonState.REPEAT;
} else {
state = (Keyboard.getEventKeyState()) ? ButtonState.DOWN : ButtonState.UP;
}
Input input = InputType.KEY.getInput(Keyboard.getEventKey());
result.add(new KeyboardAction(input, state, Keyboard.getEventCharacter()));
}
return result;
}
}
代码示例来源:origin: libgdx/libgdx
int keyCode = getGdxKeyCode(Keyboard.getEventKey());
char keyChar = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState() || (keyCode == 0 && keyChar != 0 && Character.isDefined(keyChar))) {
long timeStamp = Keyboard.getEventNanoseconds();
代码示例来源:origin: libgdx/libgdx
int keyCode = getGdxKeyCode(Keyboard.getEventKey());
char keyChar = Keyboard.getEventCharacter();
if (Keyboard.getEventKeyState() || (keyCode == 0 && keyChar != 0 && Character.isDefined(keyChar))) {
long timeStamp = Keyboard.getEventNanoseconds();
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void update() {
if (!context.isRenderable())
return;
Keyboard.poll();
while (Keyboard.next()){
int keyCode = Keyboard.getEventKey();
char keyChar = Keyboard.getEventCharacter();
boolean pressed = Keyboard.getEventKeyState();
boolean down = Keyboard.isRepeatEvent();
long time = Keyboard.getEventNanoseconds();
KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
evt.setTime(time);
listener.onKeyEvent(evt);
}
}
代码示例来源:origin: Vazkii/Botania
@SubscribeEvent
public static void buttonPressed(KeyboardInputEvent.Post event) {
Minecraft mc = Minecraft.getMinecraft();
if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen)
|| Keyboard.getEventKey() != ClientProxy.CORPOREA_REQUEST.getKeyCode()
|| !Keyboard.getEventKeyState()
|| Keyboard.isRepeatEvent()
|| TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty())
return;
ItemStack stack = getStackUnderMouse();
if(stack != null && !stack.isEmpty()) {
int count = 1;
int max = stack.getMaxStackSize();
if(GuiScreen.isShiftKeyDown()) {
count = max;
if(GuiScreen.isCtrlKeyDown())
count /= 4;
} else if(GuiScreen.isCtrlKeyDown())
count = max / 2;
if(count > 0) {
String name = CorporeaHelper.stripControlCodes(stack.getDisplayName());
String full = count + " " + name;
mc.ingameGUI.getChatGUI().addToSentMessages(full);
mc.player.sendChatMessage(full);
event.setCanceled(true);
}
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent evt) {
if (!Keyboard.getEventKeyState()) {
trackReleasedKeys();
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@SubscribeEvent
public void onKeyInput(KeyInputEvent evt) {
Minecraft minecraft = Minecraft.getMinecraft();
EntityPlayer player = minecraft.player;
if (player == null) {
return;
}
boolean state = Keyboard.getEventKeyState();
if (state) {
keybindingCallbacks.stream().filter(k -> k.getKeyBinding().isKeyDown()).forEach(InputCallbackDispatcher::onKeyPressed);
}
}
代码示例来源:origin: AntiqueAtlasTeam/AntiqueAtlas
/** Handle keyboard input for this GUI and its children. */
@Override
public void handleKeyboardInput() throws IOException {
boolean handled = false;
// Traverse children backwards, because the topmost child should be the
// first to process input:
ListIterator<GuiComponent> iter = children.listIterator(children.size());
while(iter.hasPrevious()) {
GuiComponent child = iter.previous();
child.handleKeyboardInput();
if (child.hasHandledKeyboard) {
child.hasHandledKeyboard = false;
handled = true;
}
}
if (!handled) {
if (Keyboard.getEventKeyState()) {
this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
}
}
}
代码示例来源:origin: mezz/JustEnoughItems
private boolean handleKeyEvent() {
char typedChar = Keyboard.getEventCharacter();
int eventKey = Keyboard.getEventKey();
return ((eventKey == 0 && typedChar >= 32) || Keyboard.getEventKeyState()) &&
handleKeyDown(typedChar, eventKey);
}
代码示例来源:origin: nifty-gui/nifty-gui
private void processKeyboardEvents(@Nonnull final NiftyInputConsumer inputEventConsumer) {
while (Keyboard.next()) {
KeyboardInputEvent event = keyboardEventCreator.createEvent(Keyboard.getEventKey(),
Keyboard.getEventCharacter(), Keyboard.getEventKeyState());
// due to or short-circuiting on true, the event will get forward to keyboardEventsOut if keyboardEventsOut=true
if (!niftyHasKeyboardFocus || !inputEventConsumer.processKeyboardEvent(event)) {
keyboardEventsOut.offer(event);
}
}
}
代码示例来源:origin: Zyin055/zyinhud
public static void ClientTickEvent(ClientTickEvent event)
{
if(mc.currentScreen != null && mc.currentScreen instanceof GuiChat)
{
if(Keyboard.getEventKey() == ZyinHUDKeyHandlers.KEY_BINDINGS[1].getKeyCode())
{
if(Keyboard.getEventKeyState())
{
if(keyDown == false)
OnKeyDown();
keyDown = true;
}
else
{
//if(keyDown == true)
//OnKeyUp();
keyDown = false;
}
}
}
}
代码示例来源:origin: Mine-and-blade-admin/Battlegear2
@SubscribeEvent
public void keyDown(InputEvent.KeyInputEvent event) {
if (Keyboard.getEventKeyState() && !Keyboard.isRepeatEvent()) {
doKey(Keyboard.getEventKey());
}
}
代码示例来源:origin: ForestryMC/Binnie
public boolean isHelpMode() {
if (Keyboard.getEventKeyState()) {
if (KeyBindings.holdForHelpTooltips.isActiveAndMatches(Keyboard.getEventKey())) {
return true;
}
}
return Mouse.getEventButtonState() && KeyBindings.holdForHelpTooltips.isActiveAndMatches(Mouse.getEventButton() - 100);
}
代码示例来源:origin: WesCook/Nutrition
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void keyInput(InputEvent.KeyInputEvent event) {
// Exit on key de-press
if (!Keyboard.getEventKeyState()) {
return;
}
// If Nutrition key is pressed, and F3 key is not being held (F3+N toggles Spectator mode)
if (ClientProxy.keyNutritionGui.isKeyDown() && !Keyboard.isKeyDown(Keyboard.KEY_F3)) {
openNutritionGui();
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
@Override
public void handleKeyboardInput() throws IOException {
int key = Keyboard.getEventKey();
boolean state = Keyboard.getEventKeyState();
char ch = Keyboard.getEventCharacter();
ActivationEvent evt = new ActivationEvent(state ? Listener.KEY_DOWN : Listener.KEY_UP, key, ch, state);
for (GuiElement element : this.elements) {
element.handleKeyboardInput(evt);
}
if (selectedWidget == null) {
super.handleKeyboardInput();
}
}
代码示例来源:origin: com.ardor3d/ardor3d-lwjgl
@Override
protected KeyEvent computeNext() {
if (!Keyboard.next()) {
return endOfData();
}
final int keyCode = Keyboard.getEventKey();
final boolean pressed = Keyboard.getEventKeyState();
final char keyChar = Keyboard.getEventCharacter();
final Key k = LwjglKey.findByCode(keyCode);
return new KeyEvent(k, pressed ? KeyState.DOWN : KeyState.UP, keyChar);
}
}
代码示例来源:origin: Vazkii/Quark
@SubscribeEvent
public void onKeypress(GuiScreenEvent.KeyboardInputEvent.Pre event) {
if(searchBar != null && searchBar.isFocused() && Keyboard.getEventKeyState()) {
char eventChar = Keyboard.getEventCharacter();
int eventCode = Keyboard.getEventKey();
searchBar.textboxKeyTyped(eventChar, eventCode);
text = searchBar.getText();
event.setCanceled(eventCode != 1);
}
}
代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util
protected synchronized boolean getNextDeviceEvent(Event event) throws IOException {
if (!org.lwjgl.input.Keyboard.isCreated())
return false;
if (!org.lwjgl.input.Keyboard.next())
return false;
int lwjgl_key = org.lwjgl.input.Keyboard.getEventKey();
if (lwjgl_key == org.lwjgl.input.Keyboard.KEY_NONE)
return false;
Component.Identifier.Key key_id = KeyMap.map(lwjgl_key);
if (key_id == null)
return false;
Component key = getComponent(key_id);
if (key == null)
return false;
float value = org.lwjgl.input.Keyboard.getEventKeyState() ? 1 : 0;
event.set(key, value, org.lwjgl.input.Keyboard.getEventNanoseconds());
return true;
}
代码示例来源:origin: mezz/JustEnoughItems
@Override
protected boolean onMouseClicked(int mouseX, int mouseY) {
if (Config.isOverlayEnabled()) {
if (Keyboard.getEventKeyState() && (Keyboard.getEventKey() == Keyboard.KEY_LCONTROL || Keyboard.getEventKey() == Keyboard.KEY_RCONTROL)) {
Config.toggleCheatItemsEnabled();
} else {
Minecraft minecraft = Minecraft.getMinecraft();
if (minecraft.currentScreen != null) {
GuiScreen configScreen = new JEIModConfigGui(minecraft.currentScreen);
parent.updateScreen(configScreen, false);
minecraft.displayGuiScreen(configScreen);
}
}
return true;
}
return false;
}
}
代码示例来源:origin: us.ihmc.thirdparty.jme/jme3-lwjgl
public void update() {
if (!context.isRenderable())
return;
Keyboard.poll();
while (Keyboard.next()){
int keyCode = Keyboard.getEventKey();
char keyChar = Keyboard.getEventCharacter();
boolean pressed = Keyboard.getEventKeyState();
boolean down = Keyboard.isRepeatEvent();
long time = Keyboard.getEventNanoseconds();
KeyInputEvent evt = new KeyInputEvent(keyCode, keyChar, pressed, down);
evt.setTime(time);
listener.onKeyEvent(evt);
}
}
内容来源于网络,如有侵权,请联系作者删除!