keycode

Java ball moving

匿名 (未验证) 提交于 2019-12-03 01:44:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My problem is that the ball turns into a line once moved. Here is the code: package Java; import java.awt.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.*; public class javagame extends JFrame { private Image dbImage; private Graphics dbg; int x, y; public class AL extends KeyAdapter { public void keyPressed (KeyEvent e) { int keyCode = e.getKeyCode(); if(keyCode == e.VK_LEFT) { x-= 5; } if(keyCode == e.VK_RIGHT) { x+= 5; } if(keyCode == e.VK_UP) { y-= 5; } if(keyCode == e.VK_DOWN) { y+= 5; } } public

KeyboardEvent in Chrome, keyCode is 0

匿名 (未验证) 提交于 2019-12-03 01:41:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to set keyCode on dispatched event object . On button click, event is raised on textbox control to simulating keydown event. Event is raised successfully, but keyCode is 0. I need to send event object with correct keyCode to textbox. I've been using code from here . How to set keyCode value in dispatched event? 回答1: I am amazed that this bug has been sitting there for ages. There seems to be a workaround using generic events. Here's a demo: http://jsbin.com/awenaq/3 回答2: It looks like it's been a bit since you asked this so you

Keydown Simulation in Chrome fires normally but not the correct key

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to simulate keydown events on a given textarea element in an html page. Since I am using chrome, I called initKeyboardEvent on my variable and I passed the keyCode I want to type into the textarea. Here is what I tried: var keyEvent = document . createEvent ( 'KeyboardEvent' ); keyEvent . initKeyboardEvent ( 'keydown' , true , false , null , 0 , false , 0 , false , 77 , 0 ); inputNode . dispatchEvent ( keyEvent ); In this code I'm typing the letter m however the textarea is only getting the keyCode 13 which is the Enter key.

Android: How can I set a listener to the MenuButton?

匿名 (未验证) 提交于 2019-12-03 01:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to do a custom action when pressing on the Menu button on the phone. Is it possible to set an onClickListener (or similar) on the button and if so, how? onCreateOptionsMenu is only called the first time the button is pressed - I've already tried this. 回答1: Usually you shouldn't override MENU behavior as users expect menu to appear, however you can use something along these lines: /* (non-Javadoc) * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent) */ @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (

Handling Soft Keyboard Navigation Arrows

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Here i am using ViewPager for Fragments, i used custom view pager for controlling navigation. here is the class, public class NonSwipeableViewPager extends ViewPager { public NonSwipeableViewPager(Context context) { super(context); setMyScroller(); } public NonSwipeableViewPager(Context context, AttributeSet attrs) { super(context, attrs); setMyScroller(); } @Override public boolean onInterceptTouchEvent(MotionEvent event) { // Never allow swiping to switch between pages return false; } @Override public boolean onTouchEvent(MotionEvent event

How to block the back key in android when using Qt

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to prevent the app im doing to exit if someone pushes the back key on an Android device so I can send a messagebox to ask if the user wants to leave the app or not, I found that using: @Override void MainWindow::onBackPressed() { ... } I could handle that event, I tried it on my necessitas project and it didn't work. Can qtkeyevent handle this? or is there another way to do it? I block it using this: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ( (keyCode == KeyEvent.KEYCODE_BACK) ) { //moveTaskToBack(true);

onBackPressed not close Current Activity In Android

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I created an app for playing videos. It works fine but the problem is - when I press the back button on the device the Activity is not closing. The video is playing in the Background. I am using onBackpressed() . How to close the current activity? 回答1: put this code.... @Override public void onBackPressed() { finish(); } 回答2: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { //close you app or do what ever you want } return super.onKeyDown(keyCode, event); } 回答3: You have two way for

angularJs回车事件

匿名 (未验证) 提交于 2019-12-03 00:37:01
ng-keyup 完成, ng-keyup 指令用于告诉 AngularJS 在指定 HTML 元素上按键松开时需要的操作。 ng-keyup 指令不会覆盖元素的原生 onkeyup 事件, 事件触发时, ng-keyup 表达式与原生的 onkeyup 事件将都会执行。 因此,只需要在想调用回车事件的元素使用 ng-keyup 指令和对应的事件即。 举个栗子: <input type= "text" ng-keyup= "enterEvent($event)" ng-model= "searchKey" > // 关键字搜索 $scope .keySearch = function () { alert( "回车事件" ) }; $scope .enterEvent = function (e) { var keycode = window.event ? e.keyCode : e.which; if (keycode== 13 ){ $scope .keySearch(); } }; 文章来源: angularJs回车事件

Android--对话框显示和退出动画

匿名 (未验证) 提交于 2019-12-03 00:36:02
效果:对话框会从顶部滚到中间显示,点击取消就会从中间滚到下方退出界面 实现: 1.在res下创建anim文件夹,然后创建两个Animation resourse file文件: dialog_enter.xml: <? xml version= "1.0" encoding= "utf-8" ?> < set xmlns: android = "http://schemas.android.com/apk/res/android" > <!--从上进入到中间--> < translate android :duration= "200" android :fromYDelta= "-100%" /> </ set > dialog_out.xml: <? xml version= "1.0" encoding= "utf-8" ?> < set xmlns: android = "http://schemas.android.com/apk/res/android" > <!--从中间到底部退出--> < translate android :fromYDelta= "0" android :toYDelta= "100%" android :duration= "200" /> </ set > 2.在style.xml文件里设置对话框的动画样式: < style name=

Fragment的OnkeyDown处理方法

匿名 (未验证) 提交于 2019-12-03 00:36:02
由于只有Activity中才存在onKeyDown()方法监听,Fragment并不存在,那如何在Fragment中去监听遥控器的按键事件呢?这里我列出我使用的1种方法,供大家讨论一下,欢迎指正。 首先在BaseFragment实现自己需要的抽象方法 public abstract class BaseFragment extends Fragment { public abstract void onShow (); public abstract void requestFocus (); public abstract void clearFocus (); public boolean isFocus (){ return getView (). hasFocus ();}; //这里的是我们的重点 public abstract boolean onKeyDown ( KeyEvent event ); } 在我们FragMent依赖的Activity中重写onKeyDown(),这里有2种方式进行控制按键,<1>:外部法先在Activity看是否要去响应该按键,再去Fragment进行判断。<2>:可以先在Framgent里面根据需要判断按键事件,再在Activity中进行判断,下面我列出第一种方式。 //环境在Activity中 @Override public