當前位置: 首頁>>代碼示例>>Java>>正文


Java Keyboard.getEventKey方法代碼示例

本文整理匯總了Java中org.lwjgl.input.Keyboard.getEventKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.getEventKey方法的具體用法?Java Keyboard.getEventKey怎麽用?Java Keyboard.getEventKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.lwjgl.input.Keyboard的用法示例。


在下文中一共展示了Keyboard.getEventKey方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dispatchKeypresses

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void dispatchKeypresses()
{
    int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();

    if (i != 0 && !Keyboard.isRepeatEvent())
    {
        if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L)
        {
            if (Keyboard.getEventKeyState())
            {
                if (i == this.gameSettings.keyBindFullscreen.getKeyCode())
                {
                    this.toggleFullscreen();
                }
                else if (i == this.gameSettings.keyBindScreenshot.getKeyCode())
                {
                    this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc));
                }
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:23,代碼來源:Minecraft.java

示例2: dispatchKeypresses

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void dispatchKeypresses()
{
    int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();

    if (i != 0 && !Keyboard.isRepeatEvent())
    {
        if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L)
        {
            if (Keyboard.getEventKeyState())
            {
                if (this.gameSettings.keyBindFullscreen.isActiveAndMatches(i))
                {
                    this.toggleFullscreen();
                }
                else if (this.gameSettings.keyBindScreenshot.isActiveAndMatches(i))
                {
                    this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc));
                }
            }
            else if (this.currentScreen instanceof GuiControls) ((GuiControls)this.currentScreen).buttonId = null;
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:24,代碼來源:Minecraft.java

示例3: onGuiKeyboardEvent

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public void onGuiKeyboardEvent(GuiScreenEvent.KeyboardInputEvent.Post event) {
	if (Keyboard.getEventKeyState()) {
		int eventKey = Keyboard.getEventKey();
		if (KeyBindings.TOGGLE.isActiveAndMatches(eventKey)) {
			Config.toggleEnabled();
			event.setCanceled(true);
		} else if (KeyBindings.ZOOM_IN.isActiveAndMatches(eventKey)) {
			Config.increaseZoom();
			event.setCanceled(true);
		} else if (KeyBindings.ZOOM_OUT.isActiveAndMatches(eventKey)) {
			Config.decreaseZoom();
			event.setCanceled(true);
		}
	}
}
 
開發者ID:mezz,項目名稱:ItemZoom,代碼行數:17,代碼來源:EventHandler.java

示例4: update

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
 * Game loop update
 */
public void update() {
	while (Keyboard.next()) {
		if (Keyboard.getEventKeyState()) {
			if (Keyboard.getEventKey() == Keyboard.KEY_Q) {
				// play as a one off sound effect
				oggEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_W) {
				// replace the music thats curretly playing with 
				// the ogg
				oggStream.playAsMusic(1.0f, 1.0f, true);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_E) {
				// replace the music thats curretly playing with 
				// the mod
				modStream.playAsMusic(1.0f, 1.0f, true);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_R) {
				// play as a one off sound effect
				aifEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
			if (Keyboard.getEventKey() == Keyboard.KEY_T) {
				// play as a one off sound effect
				wavEffect.playAsSoundEffect(1.0f, 1.0f, false);
			}
		}
	}
	
	// polling is required to allow streaming to get a chance to
	// queue buffers.
	SoundStore.get().poll(0);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:36,代碼來源:TestUtils.java

示例5: onKeyEvent

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Inject(method = "runTickKeyboard", at = @At(value = "INVOKE_ASSIGN", target = "org/lwjgl/input/Keyboard.getEventKeyState()Z", remap = false))
private void onKeyEvent(CallbackInfo ci) {
    if (currentScreen != null)
        return;

    boolean down = Keyboard.getEventKeyState();
    int key = Keyboard.getEventKey();
    char ch = Keyboard.getEventCharacter();

    ClientAPI.EVENT_BUS.post(down ? new KeyEvent(key, ch) : new KeyUpEvent(key, ch));
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:12,代碼來源:MixinMinecraft.java

示例6: handleKeyboardInput

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void handleKeyboardInput()
{
    if(Keyboard.getEventKeyState())
    {
        if(Keyboard.getEventKey() == mc.gameSettings.keyFullscreen.keyCode)
        {
            mc.gameSettings.fullscreen = !mc.gameSettings.fullscreen;
            mc.gameSettings.saveOptions();
            mc.toggleFullscreen();
            return;
        }
        keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
    }
}
 
開發者ID:jd-lang,項目名稱:betaexpansion,代碼行數:15,代碼來源:GuiScreen.java

示例7: handleKeyboardInput

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
/**
 * Handles keyboard input.
 */
public void handleKeyboardInput() throws IOException
{
    char c0 = Keyboard.getEventCharacter();

    if (Keyboard.getEventKey() == 0 && c0 >= 32 || Keyboard.getEventKeyState())
    {
        this.keyTyped(c0, Keyboard.getEventKey());
    }

    this.mc.dispatchKeypresses();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:15,代碼來源:GuiScreen.java

示例8: invoke

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
public void invoke(Event e) {
    InputEvent.KeyInputEvent event = (InputEvent.KeyInputEvent) e;
    if (!Keyboard.getEventKeyState()) return;
    if (Keyboard.getEventKey() == Keyboard.KEY_NONE) return;
    new KeypressEvent(Keyboard.getEventKey()).call();
}
 
開發者ID:Ygore,項目名稱:bit-client,代碼行數:8,代碼來源:KeypressEventDispatcher.java

示例9: onKeyPress

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void onKeyPress()
{
	if(!WurstClient.INSTANCE.isEnabled())
		return;
	
	int keyCode = Keyboard.getEventKey();
	if(keyCode == 0 || !Keyboard.getEventKeyState())
		return;
	String keyName = Keyboard.getKeyName(keyCode);
	
	KeyPressEvent event = new KeyPressEvent(keyCode, keyName);
	WurstClient.INSTANCE.events.fire(event);
	
	String commands = keybinds.getCommands(keyName);
	if(commands == null)
		return;
	
	commands = commands.replace(";", "�").replace("��", ";");
	for(String command : commands.split("�"))
	{
		command = command.trim();
		
		if(command.startsWith("."))
			cmdProcessor.runCommand(command.substring(1));
		else if(command.contains(" "))
			cmdProcessor.runCommand(command);
		else
		{
			Mod mod = mods.getModByName(command);
			
			if(mod != null)
				mod.toggle();
			else
				cmdProcessor.runCommand(command);
		}
	}
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:38,代碼來源:KeybindProcessor.java

示例10: handleKeyboardInput

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void handleKeyboardInput() throws IOException {
    if (Keyboard.getEventKey() == 1 && this.currentScreen != null) {
        this.currentScreen = null;
    } else if (Keyboard.getEventKeyState()) {
        if (this.currentScreen != null) {
            this.currentScreen.onKeyPress(Keyboard.getEventCharacter(), Keyboard.getEventKey());
        }
        super.handleKeyboardInput();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:AccountScreen.java

示例11: update

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public void update() {
	
	// Update holding tower
	if (holdingTower){
		tempTower.setX(getMouseTile().getX());
		tempTower.setY(getMouseTile().getY());
		tempTower.draw();
	}
	
	// Update all towers in the game
	for (Tower t : towerList){
		t.update();
		t.draw();
		t.updateEnemyList(waveManager.getCurrentWave().getEnemyList());
	}
	
	// Mouse Input
	if (Mouse.isButtonDown(0) && !leftMouseButtonDown)
		placeTower();
	if (Mouse.isButtonDown(1) && !rightMouseButtonDown)
		if (holdingTower)
			unpickTower();
		
	leftMouseButtonDown = Mouse.isButtonDown(0);
	rightMouseButtonDown = Mouse.isButtonDown(1);
	
	// Keyboard Input - Broken mechanics :/
	while (Keyboard.next()){
		if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()){
			Clock.ChangeMulitplier(0.2f);
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()){
			Clock.ChangeMulitplier(-0.2f);
		}
	}		
}
 
開發者ID:imaTowan,項目名稱:Towan,代碼行數:37,代碼來源:Player.java

示例12: runTickKeyboard

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Inject(method = "runTick", at = @At(
        value = "INVOKE",
        remap = false,
        target = "Lorg/lwjgl/input/Keyboard;getEventKey()I",
        ordinal = 0,
        shift = At.Shift.BEFORE))
public void runTickKeyboard(CallbackInfo callback) throws IOException {
    int key = Keyboard.getEventKey();
    boolean state = Keyboard.getEventKeyState();

    if (key != Keyboard.KEY_NONE)
        EventManager.post(new KeyEvent(key, state));
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:14,代碼來源:MixinMinecraft.java

示例13: isEnableKeyHeld

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
private static boolean isEnableKeyHeld() {
	if (Keyboard.getEventKeyState()) {
		int eventKey = Keyboard.getEventKey();
		if (KeyBindings.HOLD.isActiveAndMatches(eventKey)) {
			return true;
		}
	}
	return false;
}
 
開發者ID:mezz,項目名稱:ItemZoom,代碼行數:10,代碼來源:EventHandler.java

示例14: handleKeyboardInput

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
@Override
public void handleKeyboardInput() throws IOException {
    int keyCode = Keyboard.getEventKey();
    if(keyCode == Keyboard.KEY_NONE || keyCode >= Keyboard.KEYBOARD_SIZE) return; // unknown key or key index greater than what lwjgl supports

    if(keyCode == Keyboard.KEY_ESCAPE) {
        MC.displayGuiScreen(null);
        return;
    }

    InputEntry entry = inputs.computeIfAbsent(keyCode, i -> new InputEntry(InputEntry.KEYBOARD, keyCode));

    boolean down = Keyboard.getEventKeyState();
    long currentTimeMS = System.currentTimeMillis();

    GuiKeyEvent.Type type;
    if(entry.getTicks() < 0) { // initially pressed
        if(!down) return; // stop executing if key hasnt been initially pressed AND the key is being released (double release event)
        type = GuiKeyEvent.Type.PRESSED;
        entry.setTimePressed(currentTimeMS); // update last click time
    } else {
        type = down ? GuiKeyEvent.Type.DOWN : GuiKeyEvent.Type.RELEASED;
    }

    // update ticks
    entry.incrementTicks();

    element.onKeyEvent(new GuiKeyEvent(
            type,
            keyCode,
            entry.getTicks(),
            entry.getTime(),
            currentTimeMS - entry.getTimePressed())
    );

    if(type == GuiKeyEvent.Type.RELEASED) {
        entry.setTime(entry.getTimePressed());
        entry.setTimePressed(-1);
        entry.resetTicks(); // reset ticks after event
    }

    super.handleKeyboardInput();
}
 
開發者ID:fr1kin,項目名稱:ForgeHax,代碼行數:44,代碼來源:MinecraftGuiProxy.java

示例15: onKeyPressed

import org.lwjgl.input.Keyboard; //導入方法依賴的package包/類
public static void onKeyPressed() {
	int key = Keyboard.getEventKey();
	for(Module mod : Hacks.hackList) {
		mod.onKeyPressed(key);
	}
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:7,代碼來源:Wrapper.java


注:本文中的org.lwjgl.input.Keyboard.getEventKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。