• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Key类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.googlecode.lanterna.input.Key的典型用法代码示例。如果您正苦于以下问题:Java Key类的具体用法?Java Key怎么用?Java Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Key类属于com.googlecode.lanterna.input包,在下文中一共展示了Key类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: show

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	while (true) {
		Key key = _terminal.readInput();
		if (_presenter.isGameOver())
			return;
		if(key != null && key.getCharacter() == Space){
			isStoped = !isStoped;
		}
		if (key != null && key.getKind() == Kind.Escape){
			if(isStoped)_presenter.saveState();
			return;
		}
		if(!isStoped)
			_presenter.tick(convertToDirection(key));
		Sleep();
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:20,代码来源:TerminalMazeView.java


示例2: convertToDirection

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
private DirectionKey convertToDirection(Key key) {
	if (key == null)
		return DirectionKey.None;

	switch (key.getKind()) {
	case ArrowDown:
		return DirectionKey.Down;
	case ArrowUp:
		return DirectionKey.Up;
	case ArrowLeft:
		return DirectionKey.Left;
	case ArrowRight:
		return DirectionKey.Right;
	default:
		return DirectionKey.None;
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:18,代码来源:TerminalMazeView.java


示例3: handleInput

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
public void handleInput(Key key) {
	////// The part below handles everything controlled by hotkeys and should not be changed (unless a bug is found)
	if (currentInputHandler == null){
		return;
	}
	Key.Kind keyKind = key.getKind();
	if (keyKind == Key.Kind.ArrowDown || keyKind == Key.Kind.ArrowLeft || keyKind == Key.Kind.ArrowRight || keyKind == Key.Kind.ArrowUp) {
		currentInputHandler.arrowPressed(keyKind);
	}
	else if (keyKind == Key.Kind.Enter){
		currentInputHandler.enterPressed();
	}
	else if (keyKind == Key.Kind.Backspace || keyKind == Key.Kind.Delete || keyKind == Key.Kind.End || keyKind == Key.Kind.Home || keyKind == Key.Kind.Insert || keyKind == Key.Kind.PageUp || keyKind == Key.Kind.PageDown || keyKind == Key.Kind.Tab || keyKind == Key.Kind.Escape){
		currentInputHandler.specialKeyPressed(keyKind);
	}
	else if (keyKind == Kind.NormalKey){
		currentInputHandler.normalKeyPressed(key.getCharacter());
	}
	else if (keyKind == Kind.F1 || keyKind == Kind.F2 || keyKind == Kind.F3 || keyKind == Kind.F4 || keyKind == Kind.F5 || keyKind == Kind.F6 || keyKind == Kind.F7 || keyKind == Kind.F8 || keyKind == Kind.F9 || keyKind == Kind.F10 || keyKind == Kind.F11 || keyKind == Kind.F12){
		currentInputHandler.FbuttonPressed(keyKind);
	}
}
 
开发者ID:Teascade,项目名称:Solid-Kingdom,代码行数:23,代码来源:InputHandlerManager.java


示例4: show

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	String[] names = { "        Game Over        ",
			"Do you want to play again?", "  Press Y to play again.",
			"  Press N or ESC to quit." };
	TerminalSize screenSize = _terminal.getTerminalSize();

	for (int i = 0; i < names.length; i++) {
		_terminal.moveCursor(screenSize.getColumns() / 2 - 15,
				screenSize.getRows() / 2 - 2 + i);
		writeLine(String.format("%s", names[i]));
	}

	_terminal.flush();
	while (true) {
		Key p = _terminal.readInput();
		if (p == null)
			continue;
		char ch = p.getCharacter();
		if (p.getKind() == Kind.Escape || ch == 'n')
			break;
		if (ch == 'y') {
			_continueGame = true;
			break;
		}
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:29,代码来源:TerminalGameOverView.java


示例5: show

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public void show() {
	_terminal.clearScreen();
	String[] names = _presenter.getLevelNames();
	_lvlCount = names.length;

	for (int i = 0; i < names.length; i++) {
		_terminal.moveCursor(6, 6 + i);
		writeLine(String.format("[%1$s] - %2$s", i+1, names[i]));
	}

	_terminal.flush();

	boolean isAccepted = false;
	boolean isSelected = false;
	while (!isAccepted) {
		Key p = _terminal.readInput();
		if (p == null) continue;
		if (p.getKind() == Key.Kind.Enter && isSelected) {
			isAccepted = true;
			break;
		}
		char ch = p.getCharacter();
		if (!Character.isDigit(ch)) continue;
		int index = Character.getNumericValue(ch) - 1;
		updateIndexTracker(index);
		isSelected = _presenter.setSelection(index);
	}
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:30,代码来源:TerminalLevelView.java


示例6: setUp

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
	key = Mockito.mock(Key.class);
	terminal = Mockito.mock(Terminal.class);
	terminalSize = Mockito.mock(TerminalSize.class);
	presenter = Mockito.mock(GameOverPresenter.class);
	gameOver = Mockito.spy(new TerminalGameOverView(presenter, terminal));

	Mockito.when(terminalSize.getRows()).thenReturn(100);
	Mockito.when(terminalSize.getColumns()).thenReturn(100);
	Mockito.when(terminal.getTerminalSize()).thenReturn(terminalSize);
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:13,代码来源:TerminalGameOverViewTest.java


示例7: setUp

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Before
public void setUp(){
	terminal=Mockito.mock(Terminal.class);
	presenter = Mockito.mock(HighScorePresenter.class);
	key=Mockito.mock(Key.class);
	when(terminal.getTerminalSize()).thenReturn(new TerminalSize(1000, 1000));
	when(presenter.getHighScoreInfo()).thenReturn("");
	when(terminal.readInput()).thenReturn(key);
	
}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:11,代码来源:TerminalHighScoreViewTest.java


示例8: setUp

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Before
	public void setUp() throws Exception {

		terminal = Mockito.mock(Terminal.class);
		presenter = Mockito.mock(MazePresenter.class);
//		mazeView = Mockito.spy(new TerminalMazeView(presenter, terminal));
		mazeView = new TerminalMazeView(presenter, terminal);
		key = Mockito.mock(Key.class);
	}
 
开发者ID:freeuni-sdp,项目名称:snake-15,代码行数:10,代码来源:TerminalMazeViewTest.java


示例9: addGeneralShortcuts

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
private void addGeneralShortcuts() {
	this.addWindowListener(new WindowAdapter() {

		@Override
		public void onUnhandledKeyboardInteraction(Window window, Key key) {
			if (key.getKind() == Kind.Escape)
				close();
		}

	});
}
 
开发者ID:frincon,项目名称:openeos,代码行数:12,代码来源:UnoWindow.java


示例10: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: 
		switch (k.getCharacter()) {
		case ' ':
			return new GameAction(2, 1); //next page
		default:
			return new GameAction(2, 0); // do nothing
		}
	default:
		return new GameAction(2, 0); // do nothing
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:15,代码来源:InventoryLayer.java


示例11: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
    switch (k.getKind()) {
    case NormalKey: {
        switch (k.getCharacter()) {
        case 'N':
            return new GameAction(1, 1); // generate new level
        case 'S':
            return new GameAction(1, 2); // save current level
        case 'L':
            return new GameAction(1, 3); // load saved level
        case 'q':
            return new GameAction(1, 4); // quit
        case 'h':
            return new GameAction(1, 5); // Move left
        case 'j':
            return new GameAction(1, 7); // Move down
        case 'k':
            return new GameAction(1, 6); // Move up
        case 'l':
            return new GameAction(1, 8); // Move right
        default:
            return new GameAction(1, 0); // do nothing
        }
    }
    case ArrowLeft:
        return new GameAction(1, 5); // Move left
    case ArrowUp:
        return new GameAction(1, 6); // Move up
    case ArrowDown:
        return new GameAction(1, 7); // Move down
    case ArrowRight:
        return new GameAction(1, 8); // Move right
    default:
        return new GameAction(1, 0); // do nothing
    }
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:38,代码来源:DemoLayer.java


示例12: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	if(k.getKind() == Kind.NormalKey && k.getCharacter() == ' ') {
		return new GameAction(7,1);
	}
	else {
		app.getLayers().pop();
		Layer layerBelow = app.getLayers().peek();
		app.getLayers().push(this);
		return layerBelow.getActionForKey(k);
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:13,代码来源:AnnounceLayer.java


示例13: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	if (k.getCharacter() >= 'a' && k.getCharacter() <= 'z') {
		int slot = k.getCharacter() - 'a';
		return new GameAction(2,slot); //Quaff potion in slot 
	}
	else {
		return new GameAction(2,-1); //Not valid key
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:11,代码来源:UseItemLayer.java


示例14: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: {
		switch (k.getCharacter()) {
		case 'h':
			return new GameAction(1, 1); // Move left
		case 'j':
			return new GameAction(1, 2); // Move down
		case 'k':
			return new GameAction(1, 3); // Move up
		case 'l':
			return new GameAction(1, 4); // Move right
		case ' ':
			return new GameAction(1, 5); // Close
		default:
			return new GameAction(1, 0); // do nothing
		}
	}
	case ArrowLeft:
		return new GameAction(1, 1); // Move left
	case ArrowDown:
		return new GameAction(1, 2); // Move down
	case ArrowUp:
		return new GameAction(1, 3); // Move up
	case ArrowRight:
		return new GameAction(1, 4); // Move right
	case Escape:
		return new GameAction(1,5); //Close
	default:
		return new GameAction(1, 0); // do nothing
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:33,代码来源:LookLayer.java


示例15: onKeyPressed

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
protected void onKeyPressed(Key k) {
	if (!layers.isEmpty()) {
		Layer active = layers.peek();
		active.propagateAction(active.getActionForKey(k));
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:8,代码来源:Application.java


示例16: getActionForKey

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public GameAction getActionForKey(Key k) {
	switch (k.getKind()) {
	case NormalKey: return new GameAction(0, 1);
	default: return new GameAction(0, 2);
	}
}
 
开发者ID:melloc,项目名称:roguelike,代码行数:8,代码来源:TestLayer.java


示例17: handleGlobalKeyPressed

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
public boolean handleGlobalKeyPressed(final Window sender, final Key key)
{
    if (key.getCharacter() == 'q' || key.getKind() == Kind.Escape)
    {
        shutdown();
        return true;
    }
    else if (key.getCharacter() == '?')
    {
        helpPopup.show();
        return true;
    }

    return false;
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:16,代码来源:Controller.java


示例18: onKeyPressed

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public void onKeyPressed(final Key key)
{
    if (this.controller.handleGlobalKeyPressed(this, key))
    {
        return;
    }

    if (key.getCharacter() != 'd')
    {
        super.onKeyPressed(key);
        return;
    }

    final Object selectedItem = this.directoryPanel.getListBox().getSelectedItem();

    if (selectedItem == null)
    {
        MessageBox.showMessageBox(this.gui, "Error", "No item selected.");
        return;
    }

    final Displayable displayable = (Displayable) selectedItem;

    final Object reference = displayable.getReference();

    if (reference instanceof Directory)
    {
        this.controller.deleteDiretory((Directory) reference);
    }
    else if (reference instanceof FileStatus)
    {
        this.controller.deleteFile(this.directoryPanel.getCurrentDirectory(), (FileStatus) reference);
    }
    else
    {
        MessageBox.showMessageBox(this.gui, "Error", "Can't delete this.");
    }
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:40,代码来源:MainWindow.java


示例19: onKeyPressed

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public void onKeyPressed(Key key)
{
    if (controller.handleGlobalKeyPressed(this, key) == false)
    {
        super.onKeyPressed(key);
    }
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:9,代码来源:ScanningPopup.java


示例20: keyboardInteraction

import com.googlecode.lanterna.input.Key; //导入依赖的package包/类
@Override
public Result keyboardInteraction(Key key)
{
    final Displayable selectedItem = (Displayable) getSelectedItem();

    switch (key.getKind())
    {
        case Enter:
        case ArrowRight:
            selectedItem.navigate();
            return Result.EVENT_HANDLED;

        case ArrowLeft:
            selectedItem.navigateToParent();
            return Result.EVENT_HANDLED;

        default:
            break;
    }

    switch (key.getCharacter())
    {
        case 'l':
            return super.keyboardInteraction(new Key(Kind.ArrowRight));

        case 'h':
            return super.keyboardInteraction(new Key(Kind.ArrowLeft));

        case 'k':
            return super.keyboardInteraction(new Key(Kind.ArrowUp));

        case 'j':
            return super.keyboardInteraction(new Key(Kind.ArrowDown));

        default:
            break;
    }

    return super.keyboardInteraction(key);
}
 
开发者ID:d0x,项目名称:nchadoop,代码行数:41,代码来源:DirectoryListBox.java



注:本文中的com.googlecode.lanterna.input.Key类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CSSPositionType类代码示例发布时间:2022-05-22
下一篇:
Java Danmaku类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap