KeyDown keyPressed Problem

I made a little test movie where I placed the below two
scripts, one in a movie script, and the other in a frame script.
The keyDown function in the movie script was accessible all of the
time, and the other script was only accessible while the play head
was on that frame. This is the behavior I expected.
In a larger movie (more frames, scripts, stuff…) this
is not working. The frame script successfully captures the space
bar press, however the function in the movie script doesn’t
ever fire. This is not the behavior I am looking for.
Any reason why the keyDown script in a movie script
wouldn’t fire?

"adam@blueapplestudio" wrote:
> Using keyDownScript seems to work quite well; thanks for
the guidance.
>
> Still, I don't follow why the other method works
successfully in a small test
> movie but failed in another. As long as one of them
works, I'm happy :)
The keydownScript allows keyboard activity to be detected at
a global level. Say
you have a keyDown event tied to a sprite, if you tested the
movie and the Stage
was not the active Window (say the Score was), then the
keyDown event would not
be recognised. So, in your case, it may have been in the one
test, one Director
window was active, in the second situation, a different
window was active.
regards
Dean
Director Lecturer / Consultant / Director Enthusiast
http://www.deansdirectortutorials.com/
http://www.multimediacreative.com.au
email: [email protected]

Similar Messages

  • KeyPressed problem on old phones

    Hi friends!
    I have a big problem.
    I use a Canvas, and it has a keyPressed method... This method works perfectly on my SE K800i, but on my brother's SE K700i this method doesn't work... On SE K750i doesn't work, too. I don't know, what do I have to do... Please help me!
    (Sorry for my bad english.)

    Here is my "KeyCodeTester" application's source code:
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class KeyCodeTester extends MIDlet {
        public void startApp() {
            KeyCodeCanvas myCanvas = new KeyCodeCanvas();
            Display.getDisplay(this).setCurrent(myCanvas);
        public void pauseApp() {
        public void destroyApp(boolean unconditional) {
        class KeyCodeCanvas extends Canvas{
            int kCode = 0;
            int kGameAction = 0;
            String kName = "";
            Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);
            public KeyCodeCanvas(){
                setFullScreenMode(true);
            public void paint(Graphics g){
                g.setFont(font);
                g.setColor(0,0,0);
                g.fillRect(0,0,getWidth(),getHeight());
                g.setColor(255,255,255);
                g.drawString("K�d: "+kCode, getWidth()/2, getHeight()/2-font.getHeight(), Graphics.TOP | Graphics.HCENTER);
                g.drawString("Game Action k�d: "+kGameAction, getWidth()/2, getHeight()/2, Graphics.TOP | Graphics.HCENTER);
                g.drawString("N�v: "+kName, getWidth()/2, getHeight()/2+font.getHeight(), Graphics.TOP | Graphics.HCENTER);
            public void keyPressed(int keyCode){
                kCode = keyCode;
                kGameAction = getGameAction(keyCode);
                kName = getKeyName(keyCode);
                repaint();
                serviceRepaints();
    }It's doesn't work with function (soft)keys.

  • HTML5 UI is unable to correctly get the information of  key-events .

    I have developed a plug-in for Illustrator CC2014.
    But, The Plug-in UI which was built with HTML5, is unable to correctly get the information of  key-events .
    As problems following.
        0-9 key press       : "keyCode" is "0"
        Shift key press     : "shiftKey"is "false"
        Alt key press        : "altKey"is"false"
    Even if acquired at any timing(keydown, keypress, keyup) symptom occurs.
    In the Windows, you can get the information of key-events is correct at the same implementation.
    In the case of the browser UI, even in the Mac, I can correctly get.
    What causes that can not be acquired key event information is correct on the plug-in?
    Also, If you have any way to get the information of key-events correctly, please let me know.

    Pulluran wrote:
    I tried the event, but it does not resolve.
    In the windows, onKeydownEvent(event) can get the event information correctly.
    in the Mac, the keyevent information was originally can be get.The problem is that the keyevent information was not the correct information.
    "in the Mac, the keyevent information was originally can be get"
    What does that mean?
    "The problem is that the keyevent information was not the correct information."
    The problem seems to be that the event contains no information, keyCode is always zero and shiftKey and altkey are always false.
    What happens if you try
    function onKeydownEvent(obj) {
    var keyCode = (obj.keyCode >= 96 && obj.keyCode <= 105) ? obj.keyCode - 48 : obj.keyCode;
    var inputStr = String.fromCharCode(keyCode);

  • How can I get around Javascipt issue with keyboard events?

    Javascript issue: keydown, keypress, keyup events cause quick search to initiate with the division key on the keypad and slash key on the keyboard. I am trying to program a graphic representation of a 10 key pad and the division (/) sign is problematic for roll over and processing based on key events. How can I get around this? further notes: Safari also has problems with key events and the division key(s) but no search function connected. Thankyou for time and attention

    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • How to trap standard function keys(f1, f2....) in jsp.

    I want to trap the standard funtion keys in jsp, so that whenever these keys are used i can maje the page take required action. Can anyone please help me by telling how to do that?

    You will have to use JavaScript. Look up the javascript keydown keypressed and keyup events.

  • RemoteApp receives multiple KeyUp events without any keys being pressed

    Hi All,
    I have a very simple winforms app that I am using to try and track down what is happening with keyboard events when using RemoteApp.
    Basically I have a form and a textbox that track the KeyDown, KeyPress and KeyUp events.
    As soon as I start my app via RemoteApp I receive multiple KeyUp events without even pressing a key.
    Does anyone know why RemoteApp would be sending these random KeyUp events.
    The code of my simple test app is as follows:
    Public Class Form1
    Dim lst As New List(Of String)
    Private Sub AddtoList(str As String)
    lst.Add(str)
    End Sub
    Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
    AddtoList("txt KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    AddtoList("txt KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
    End Sub
    Private Sub TextBox1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
    AddtoList("txt KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    AddtoList("Form Closing")
    IO.File.AppendAllLines(Application.StartupPath & "\SimpleKeyUp_v2.txt", lst)
    End Sub
    Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    AddtoList("Form KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
    AddtoList("Form KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
    End Sub
    Private Sub Form1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
    AddtoList("Form KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
    End Sub
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
    AddtoList("Form Load")
    End Sub
    End Class
    Simply opening and closing the app via RemoteApp gives the following results:
    Form Load
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 16
    txt KeyUp KeyCode is 16
    Form KeyUp KeyCode is 16
    txt KeyUp KeyCode is 16
    Form KeyUp KeyCode is 17
    txt KeyUp KeyCode is 17
    Form KeyUp KeyCode is 17
    txt KeyUp KeyCode is 17
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 18
    txt KeyUp KeyCode is 18
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form KeyUp KeyCode is 18
    txt KeyUp KeyCode is 18
    Form KeyUp KeyCode is 9
    txt KeyUp KeyCode is 9
    Form Closing
    Cheers and Thanks in Advance!
    Dwayne

    Hi,
    It seems that your issue has been out of the scope of this forum.For coding issue,I suggest you ask in the
    MSDN forum to see whether anyone can help you out.
    Regards,
    Clarence
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • F:ajax event value binding not working

    I'm trying to create an inputText composite component that generates a label, inputText and message with optional ajax capability.
    When I attempt to expose the f:ajax event property to page authors, I get the following exception:
    javax.faces.view.facelets.TagException: /resources/jimo/textEntry.xhtml @89,50 <f:ajax> '#{cc.attrs.ajaxEvent}' is not a supported event for HtmlInputText. Please specify one of these supported event names: blur, change, click, [etc...]
    The javadoc for f:ajax shows the event attribute as type javax.el.ValueExpression, but it doesn't seem that it's being evaluated as such. I'm able to expose the disabled attribute, and it's working as expected.
    Any feedback would be appreciated.
    I'm running glassfish3.0.1 with Mojarra 2.0.3 (FCS b03)
    Following is the component
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:cc="http://java.sun.com/jsf/composite">
    <!-- INTERFACE -->
    <cc:interface>
         <cc:attribute name="label" required="true" type="java.lang.String" />
         <cc:attribute name="value" required="true" />
         <cc:attribute name="size" default="15" type="int" />
    <!-- lots of other inputText supported Attributes -->
         <cc:attribute name="ajax" default="true" type="java.lang.Boolean" />
         <cc:attribute name="ajaxEvent" />
         <cc:editableValueHolder name="txtEntry" />
         <cc:attribute name="valueChangeListener" targets="txtEntry"
              method-signature="void valueChange(javax.faces.event.ValueChangeEvent)" />
    </cc:interface>
    <!-- IMPLEMENTATION -->
    <cc:implementation>
         <span class="frmLabel">
              <h:outputLabel for="txtEntry" value="#{cc.attrs.label}" />
         </span>
         <h:inputText id="txtEntry" size="#{cc.attrs.size}"
                   value="#{cc.attrs.value}">
              <f:ajax disabled="#{not cc.attrs.ajax}" execute="@this"
                        render="txtEntryMsg" event="#{cc.attrs.ajaxEvent}" />
         </h:inputText>
         <h:message id="txtEntryMsg" for="txtEntry" />
    </cc:implementation>
    </html>And a sample using page
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
              "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:jimo="http://java.sun.com/jsf/composite/jimo">
    <ui:composition template="/template.xhtml">
         <ui:param name="title" value="Test Page for textEntry Component" />
         <h:form id="formid">
              <h:panelGrid id="frmGrid" columns="1">
                   <jimo:textEntry label="Number:" ajax="true" ajaxEvent="change"
                             immediate="true" value="#{simpleBean.dataItem.num}" size="10">
                        <f:convertNumber for="txtEntry" integerOnly="true"
                                  groupingUsed="false" />
                   </jimo:textEntry>
                   <jimo:textEntry label="Description:" ajax="true" ajaxEvent="blur"
                             blur="myBlurFunction(this);"
                             value="#{simpleBean.dataItem.descr}" size="50" />
                   <jimo:textEntry label="Prior Date Validator:" ajax="true"
                             ajaxEvent="change" maxlength="10"
                             valueChangeListener="#{simpleBean.changeListener}"
                             validator="#{simpleBean.priorDateValidator}" value="08/20/2004"
                             size="20">
                        <f:convertDateTime for="txtEntry" pattern="MM/dd/yyyy" type="date"
                                  timeZone="EST" />
                   </jimo:textEntry>
              </h:panelGrid>
              <h:panelGrid columns="2">
                   <h:commandButton id="saveButton" value="Save"
                             action="#{simpleBean.saveAction}"
                             actionListener="#{simpleBean.saveActionListener}" />
                   <h:commandButton id="resetButton" value="Reset"
                             type="reset" />
                   <h:message for="saveButton" />
              </h:panelGrid>
         </h:form>
    </ui:composition>
    </html>Here's the top of the stack trace(full trace is too large for post)
    [#|2010-08-26T15:25:25.343-0400|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=24;_ThreadName=http-thread-pool-8080-(1);|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
    javax.faces.view.facelets.TagException: /resources/jimo/textEntry.xhtml @94,38 <f:ajax> '#{cc.attrs.ajaxEvent}' is not a supported event for HtmlInputText.  Please specify one of these supported event names: blur, change, click, dblclick, focus, keydown, keypress, keyup, mousedown, mousemove, mouseout, mouseover, mouseup, select, valueChange.
         at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.applyAttachedObject(AjaxHandler.java:321)
         at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.applyNested(AjaxHandler.java:292)
         at com.sun.faces.facelets.tag.jsf.core.AjaxHandler.apply(AjaxHandler.java:171)
         at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:131)
         at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:162)
         at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
         at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:94)
         at com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(ImplementationHandler.java:77)
         at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:94)
         at com.sun.faces.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:89)
         at com.sun.faces.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:79)
         at com.sun.faces.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:148)
         at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(CompositeComponentTagHandler.java:348)
         at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(CompositeComponentTagHandler.java:185)
         at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(ComponentTagHandlerDelegateImpl.java:162)
         at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:114)
    |#]

    There is a { missing from the value attribute in the code you posted.                                                                                                                                                                                           

  • Bluetooth keyboard and mouse failures

    I have brand new PowerBook G4 15" with Bluetooth. I also have brand new Bluetooth wireless Apple keyboard and mouse. I am running 10.4.5. The keyboard and mouse lose contact with the computer on a regular basis, even though they are right next to each other. Sometimes I get the error sign on the computer, sometimes not. Batteries are fresh. Reboot fixes problem. Apple tech support says "interference" might be problem, but I don't have anything nearby except Linksys wireless router. Any ideas?
    PowerBook G4 Mac OS X (10.4.5)
    PowerBook G4 Mac OS X (10.4.4)
    PowerBook G4 Mac OS X (10.4.5)

    Over the weekend my BT apple keyboard has been doing multiple strange things as well.
    First, the batteries died, something that, of course, happens from time to time. Replaced with the same brand/type as always.
    Later in the same weekend then I was typing and began suffering from a strange random keypress problem. Q for instance, began equaling 'ew' while space started equaling '['.
    Odd.
    I shelved the keyboard with the intent to call Apple today.
    Now I get home from work, reconnect the KB, and lo-and-behold, it works! I was thrilled. Now, after 3 hours of use, the same problems start back up. This is obviously therefore not a KB related issue but a software related issue or else it would now reliably do the same key oddities that it had been doing.
    I've trashed the BT preferences and am about to restart, but I don't think it's time to buy a new keyboard just yet for those of you having similar BT keyboard problems.

  • TEMPCOMBO opens in double click

    Hi,
    https://social.msdn.microsoft.com/Forums/office/en-US/01ba96be-5801-4eda-95d9-e01cea835567/temp-combobox-doesnot-work-in-protected-sheet?forum=exceldev
    '==========================
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
      Cancel As Boolean)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Set ws = ActiveSheet
    ScreenUpdating = False
    Set cboTemp = ws.OLEObjects("TempCombo")
      On Error Resume Next
      With cboTemp
      'clear and hide the combo box
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
      End With
    On Error GoTo errHandler
      If Target.Validation.Type = 3 Then
        'if the cell contains a data validation list
        Cancel = True
        Application.EnableEvents = False
        'get the data validation formula
        str = Target.Validation.Formula1
        str = Right(str, Len(str) - 1)
        With cboTemp
          'show the combobox with the list
          .Visible = True
          .Left = Target.Left
          .Top = Target.Top
          .Width = Target.Width + 5
          .Height = Target.Height + 5
          .ListFillRange = str
          .LinkedCell = Target.Address
        End With
        cboTemp.Activate
        'open the drop down list automatically
        Me.tempcombo.DropDown
      End If
    errHandler:
      Application.EnableEvents = True
      ScreenUpdating = True
      Exit Sub
    End Sub
    '=========================================
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Application.EnableEvents = False
    Application.ScreenUpdating = True
    If Application.CutCopyMode Then
      'allow copying and pasting on the worksheet
      GoTo errHandler
    End If
    Set cboTemp = ws.OLEObjects("TempCombo")
      On Error Resume Next
      With cboTemp
        .Top = 10
        .Left = 10
        .Width = 0
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
        .Value = ""
      End With
    errHandler:
      Application.EnableEvents = True
      Exit Sub
    End Sub
    '====================================
    'Optional code to move to next cell if Tab or Enter are pressed
    'from code by Ted Lanham
    '***NOTE: if KeyDown causes problems, change to KeyUp
    Private Sub TempCombo_KeyDown(ByVal _
            KeyCode As MSForms.ReturnInteger, _
            ByVal Shift As Integer)
        Select Case KeyCode
            Case 9 'Tab
                ActiveCell.Offset(0, 1).Activate
            Case 13 'Enter
                ActiveCell.Offset(1, 0).Activate
            Case Else
                'do nothing
        End Select
    End Sub
    '===================================="
    The question is , the tempcombo needs double click to open dropdown. Is it possible that it appears when mouce hover over the cell or with one click ??

    Hi drsantoshsinghrathore,
    I made a simple with your code, and I could reproduce your issue. Based on the code, I think this behavior is expected since the tempcombo needs double click to open dropdown in your code. And if you want to achieve it with one click, I think you could remove
    the "Worksheet_BeforeDoubleClick" and modify the "Worksheet_SelectionChange".
    The simple code as below:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Dim wsList As Worksheet
    Set ws = ActiveSheet
    Set wsList = Sheets("ValidationLists")
    Set cboTemp = ws.OLEObjects("TempCombo")
    On Error Resume Next
    With cboTemp
    .ListFillRange = ""
    .LinkedCell = ""
    .Visible = False
    End With
    On Error GoTo errHandler
    If Target.Validation.Type = 3 Then
    Application.EnableEvents = False
    str = Target.Validation.Formula1
    str = Right(str, Len(str) - 1)
    With cboTemp
    .Visible = True
    .Left = Target.Left
    .Top = Target.Top
    .Width = Target.Width + 15
    .Height = Target.Height + 5
    .ListFillRange = str
    .LinkedCell = Target.Address
    End With
    cboTemp.Activate
    Else
    With cboTemp
    .Top = 10
    .Left = 10
    .Width = 0
    .ListFillRange = ""
    .LinkedCell = ""
    .Visible = False
    .Value = ""
    End With
    End If
    errHandler:
    Application.EnableEvents = True
    Exit Sub
    End Sub
    Best Regards,
    Edward
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

  • My Macbook a 2.4 GHZ intel machine refuses to type the 1st key.,

    My Macbook a 2.4 GHZ intel machine refuses to type the 1st key.
    Not all the time, but intermittently.
    A Firmware update to address this issue didn't fix it.
    Most annoying when doing searches or especially when typing passwords.
    elp  elp elp

    So I'm fooling myself by using this forum to attempt to get help?
    There are no moderators?
    No one to say...your issue is solved here...
    or your issue may never be solved? (MY SITUATION)
    I have a 1st Keypress problem that wasn't fixed by any firmware update.
    I don't know how many times its screwed me during LOG-INS
    and SEARCHES become annoying!
    So answer is BUY a new COMPUTER?

  • Problems with the slight delay of keyPressed.

    Hi all!
    I just joined the wonderful sdn network, so HELLO EVERYONE :D
    I studyed some java in unversity, but never in depth, and ive recently found myself yearning after it, so recently i decided to try and teach myself!
    Unfortuantly ive hit abit of a problem, im trying to make a pacman game, hopfully develop it beyond the original and make it more innovative.
    Ive come across two problems
    1. My applet doesnt seem to have any focus until ive clicked onto it - i cant figure out what needs the focus and which focus method i should use or where the code should go!
    2. Although ive got my pacman displayed with a nice munching motion (which im quite proud of ^_^ ) and he moves when the specific keys are pressed, theres a slight delay when i try and change direction, or when i first keyPress. Hopefully you can see what i mean when you run my code, or maybe you already know what im talking about!
    I have a feeling its to do with the keyPressed code, since it only kicks in when the key is down, rather then when its keyDowning(if thats even a word!) is there a way to remove that delay so movement is seamless?
    So id be very grateful if you could advise me on what my first mistake was, and what i could do with my second problem!
    Thank you, my code is below, and please feel free to share some POSTIVE critisim, on my code, or advice on what steps to take next or in coding in general!
    CHEERS!
    sskenth
    4 classes - AnimationThread, Pacman, PaintSurface, Room
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.geom.*;
    class AnimationThread extends Thread
         JApplet c;
         int threadSpeed = 20; // this allows the pacman speed to be reduced i.e. negative slow pill... change to 100 for slow!
         public AnimationThread(JApplet c)
              this.c=c;
         public void run()
              while(true)
                   c.repaint();
                   try
                        Thread.sleep(threadSpeed);
                   catch(InterruptedException ex)
                        //swallow the exception
    import java.awt.geom.*;
    import java.awt.event.*;
    class Pacman extends Arc2D.Float //implements KeyListener //setArc(double x, double y, double w, double h, double angSt, double angExt, int closure)
              private int diameter;
              private int x_speed,y_speed;
              private int width = Room.WIDTH;
              private int height = Room.HEIGHT;
              private     int mouth = 10;// mouth is the amount it opens by! -1 is opening, +1 is closing
                             // mouth - =1 makes it spin!
              public Pacman(int diameter)
                   super((int)(Math.random() * (Room.WIDTH - 20) + 1), (int)(Math.random() * (Room.HEIGHT - 20) + 1),diameter,diameter,210,300,2);
                   this.diameter = diameter;
                   //this.x_speed = (int)(Math.random()*5+1);
                   //this.y_speed = (int)(Math.random()*5+1);
                   this.x_speed = 10;
                   this.y_speed = 10;
         public void move(int e)
                   if(e == KeyEvent.VK_UP)
                   this.setAngleStart(120);
                   super.y -=y_speed;
                   if(e == KeyEvent.VK_DOWN)
                   this.setAngleStart(300);
                   super.y +=y_speed;
                   if(e == KeyEvent.VK_LEFT)
                   this.setAngleStart(210);
                   super.x -=x_speed;
                   if(e == KeyEvent.VK_RIGHT)
                   this.setAngleStart(30);
                   super.x +=x_speed;
                   //System.out.println(direction);
              public void mouth()
                        if(this.getAngleExtent()  >= 360)
                        mouth = -10;
                        if(this.getAngleExtent()  <= 270)
                        mouth = 10;
                   double angExt = this.getAngleExtent();
                   this.setAngleExtent(angExt +=mouth);
                   //     System.out.println(getAngleExtent());
    import java.awt.event.*;
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.util.*;
    class PaintSurface extends JComponent
              public ArrayList<Pacman> pacmans = new ArrayList<Pacman>();
              public static Pacman pacman;
              public PaintSurface()
                    pacman = new Pacman(50); //diameter of pacman
                   //for(int i = 0; i <10; i++)
                        //pacmans.add(new Pacman(50));
              public void paint (Graphics g)
                   Graphics2D g2 = (Graphics2D)g;
                   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                   //g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.50F)); //adds transparency
                   g2.setColor(Color.YELLOW);
                   //for(Pacman pacman: pacmans)
                        //pacman.move();
                        pacman.mouth();
                        g2.fill(pacman);
    import java.applet.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    public class Room extends JApplet implements KeyListener
              public static final int WIDTH = 1000;
              public static final int HEIGHT = 300;
              private PaintSurface canvas;
              public void init()
                   this.setSize(WIDTH, HEIGHT);
                   canvas = new PaintSurface();
                   this.add(canvas,BorderLayout.CENTER);
                   Thread t = new AnimationThread(this);
                   t.start();
                   addKeyListener(this);
                   //canvas.requestFocus();
                   this.requestFocusInWindow();
              //frame.pack();  //Realize the components.
                  //This button will have the initial focus.
                 // button.requestFocusInWindow();
              public void keyReleased(KeyEvent e)
                             //System.out.println("KeyRELEASED "+e);
                             //int keyCode = e.getKeyCode();
                             //     PaintSurface.pacman.move(keyCode);
                        public void keyPressed(KeyEvent e)
                        //System.out.println("KeyRELEASED "+e);
                        int keyCode = e.getKeyCode();
                                  PaintSurface.pacman.move(keyCode);
                        public void keyTyped(KeyEvent e)

    Well i did as you both said, and it worked! thought id just put the code up for anyone who was wondering what it looked like, just replace the pacman class above with this new one and start the thread!
    import java.awt.geom.*;
    import java.awt.event.*;
    class Pacman extends Arc2D.Float implements Runnable //implements KeyListener //setArc(double x, double y, double w, double h, double angSt, double angExt, int closure)
              private int diameter;
              public int x_speed,y_speed;
              private int width = Room.WIDTH;
              private int height = Room.HEIGHT;
              private     int mouth = 10;// mouth is the amount it opens by! -1 is opening, +1 is closing
                             // mouth - =1 makes it spin!
              public static String direction;
              public Pacman(int diameter)
                   //super((int)(Math.random() * (Room.WIDTH - 20) + 1), (int)(Math.random() * (Room.HEIGHT - 20) + 1),diameter,diameter,210,300,2);
                   super(100 , 100,diameter,diameter,210,300,2);
                   this.diameter = diameter;
                   //this.x_speed = (int)(Math.random()*5+1);
                   //this.y_speed = (int)(Math.random()*5+1);
                   this.x_speed = 10;
                   this.y_speed = 10;
                   //Thread t = new GameLoop(this);
                   //t.start();
         public void move(int e)
                   if(e == KeyEvent.VK_UP)
                   this.setAngleStart(120);
                   direction = "UP";
                   //movement();
                   //super.y -=y_speed;
                   if(e == KeyEvent.VK_DOWN)
                   this.setAngleStart(300);
                   direction = "DOWN";
                   //movement();
                   //super.y +=y_speed;
                   if(e == KeyEvent.VK_LEFT)
                   this.setAngleStart(210);
                   direction = "LEFT";
                   //movement();
                   //super.x -=x_speed;
                   if(e == KeyEvent.VK_RIGHT)
                   this.setAngleStart(30);
                   direction = "RIGHT";
                   //movement();
                   //super.x +=x_speed;
         /*public void move(String s)
                   if(direction == "UP")
                   super.y -=y_speed;
                   if(direction == "DOWN")
                   super.y +=y_speed;
                   if(direction == "LEFT")
                   super.x -=x_speed;
                   if(direction == "RIGHT")
                   super.x +=x_speed;
              public void mouth()
                        if(this.getAngleExtent()  >= 360)
                        mouth = -10;
                        if(this.getAngleExtent()  <= 270)
                        mouth = 10;
                   double angExt = this.getAngleExtent();
                   this.setAngleExtent(angExt +=mouth);
                   //     System.out.println(getAngleExtent());
              public void movement()
                   if(direction == "UP")
                   super.y -=y_speed;
                   if(direction == "DOWN")
                   super.y +=y_speed;
                   if(direction == "LEFT")
                   super.x -=x_speed;
                   if(direction == "RIGHT")
                   super.x +=x_speed;
                        if((direction == null) || (direction  ==""))
         public void run()
              while(true)
                        movement();
                   if((direction == null) || (direction  ==""))
                   try
                        Thread.sleep(20);
                   catch(InterruptedException e)
    }

  • Lost keypresses and mouse clicks:  Hardware problem?

    I recently bought an Intel MBP, and I've been noticing strange behaviors with regard to keypresses and mouse (touchpad) clicks getting lost sometimes. The problems I'm having are hard to reproduce intentionally, but I can hear the keypresses and mouse button clicks when I do them, yet nothing happens. While it's possible, that I sometimes am hitting the wrong key, I have been paying closer attention lately to this problem, and of course, the mouse button kinda hard to hit incorrectly. Here are some examples of weird things I encounter:
    If I click in a text field in Safari, sometimes the first keypress (and only the first) will get lost.
    Sometimes, the first keypress I type right after clicking gets lost. For instance, just now, I noticed a typo in the above sentence, so I clicked on the character and hit the Delete key. The cursor was in the right place, but the delete didn't happen. I had to press the key again.
    Sometimes, even when the window for sure has focus and the pointer is squarely pointing to a link, the first click on the link won't take. I have to click it again. Since Safari doesn't have adequate feedback for when you click something, that can get particularly frustrating. Similar things happen with buttons in applications or on the title bar.
    If I'm using an X11 app, and I copy/paste with the clipboard, the touchpad won't respond to movement for 2 or 3 seconds afterward. This is particularly visible with "nedit". I don't think this is an "ignore accidental touchpad input" issue, because this only happens with clipboard actions; other keys don't have this effect. I haven't noticed this with native apps.
    However, I have noticed in X11 and native apps, sometimes, Ctrl/Cmd-C and Ctrl/Cmd-V will be ignored. They're never ignored if I selected the text using the keyboard (shift+arrows), but if I select the text with the mouse and then use the shortcut to copy, the copy/paste sometimes doesn't happen.
    I have noticed that if I am more deliberate about clicks (make sure to hold the button down longer), the probability of losing the event SEEMS to be reduced, but not eliminated. Is there a debounce circuit involved that's causing me trouble?
    This kind of loss of input is unusual to me. I have a number of Windows and Linux PCs, and I've never experienced this sort of thing. I've also used a few Macs at school before I got this one and didn't notice anything weird.
    Can anyone shed some light on this for me? It would seem odd that I should have to modify my keyboard/mouse using behavior when switching to the Mac. If the problem is hardware, how can I prove it? (Perhaps I could boot Knoppix from a CD and mess around a bit.) If the problem is software, is this a case of MacOS trying to second-guess user input?
    Thanks!

    Theosib,
    Apple regularly monitors these boards, but you may never see a response from Apple directly. Assume this is a user to user forum. If you are having a problem with the computer and need a response from Apple call 1-800-APLCARE and speak to customer relations at that office if the technician is not able to satisfy your needs.
    Your problem while not unheard of, is more uncommon than the boards may make you believe.
    Remember, Spotlight is constantly indexing. If your hard drive is overfull, it may take longer for Spotlight to index, thus cause a multitasking delay. If you have many Dashboard widgets, they may all be trying to access the net for updates at once, and again, a delay might happen. I've written a FAQ* about several other factors which may affect Mac OS X speed, which could in theory also affect keyboard input:
    http://www.macmaps.com/Macosxspeed.html
    And of course, you should always check Apple menu -> System Preferences -> Keyboard and Mouse to make sure your input settings are the ones most comfortable for you when using the keyboard. It is possible a repeat rate could cause a delay.
    Edit: I attempted to answer another of your questions here recently with an update:
    http://discussions.apple.com/click.jspa?searchID=-1&messageID=3988468
    Please take a look and see if it answers your question.
    * Links to my FAQs may give me some compensation.

  • Event problem - slow/delayed reaction to keypresses!

    Hi all!
    Im trying to implement a first person free mouse view with strafe in the game im working on. I use KeyListener interface and my problem is that when I hold down a key it fires a KeyEvent to begin with! Then after a delay of aproximately half a second to a second more event are being fired. It gives really slow reaction - something that I can not use in my game. What to do? If someone has a good fix to this issue please post a little code snippet I can check out.
    I wish you all a good day.

    It just seems easier to set a bool. true when keyPressed - false when released. And then just run while trueOf course this creates an infinite loop which uses up the CPU resources. Not a very good idea.
    Yup, my thoughts exactly (see reply #4).Using a Thread or a Timer is a similiar in concept (much better then the above suggestion), but there are differences.
    For example when using a Thread your code will execute then you will sleep for a period of time. So if your code takes 100 milliseconds to execute and you sleep for 1000, then every cycle will take 1100 ms. The total length of time between events will vary between CPU's since the 100ms execution time will vary depending on the speed of your CPU. However, when using a Timer an event will fire every 1000ms whether your processing takes 100ms or 500ms. Which means your cycle time is exactly 1000ms.
    Using a Thread you must use the SwingUtilities.invokeLater to update the GUI since the code executes in a non Event Thread. However when using a Timer all the code executes in the Event Thread so you don't need to worry about SwingUtilities.invokeLater. Of course if your code is heavily CPU bound you may need to create a separate Thread anyway so you don't block the Event Thread from responding to events.
    But the main point is using a Timer will give you a cycle time of a fixed duration, whereas using a Thread will give you a variable cycle time depending on CPU and duration of executable code.
    The choice of implementation is up to the OP.

  • Problems with event KeyPressed?

    Hi,
    I want to know when a user is typing, some text, but the keyPressed event is only used, in canvas, and i m not using, canvas, i m only using simple GUI controls... is there any way to know when a user is typing text, or to know when there is nothing written, in a textbox, dinamically?
    Cheers,
    HELP MEEEEEE!!!!!

    hi,
    that u have to implement through coding there is no such method like that.
    I have implemeted the text box concept in the Canvas clas previously like that
    lakshman

  • Ibook G3 keyboard problem: one keypress causes many characters to appear...

    I have seen a iBook G3 (dual USB) for sale that I might purchase, the only problem is that the seller says that when he presses any of the F2, 2, w, s and x keys, it displays the results as if all the keys were pressed simultaneously. All these keys are aligned diagonally if you look at the keyboard. My question really is is this possibly a software issue or is it hardware?
    Thanks in advance!
    iMac G4 Mac OS X (10.4.9)
    iMac G4 Mac OS X (10.4.9)
    iMac G4   Mac OS X (10.4.9)  

    Hi, and welcome to Apple Discussions.
    This is most likely a hardware issue which will require replacing the keyboard.
    If the iBook still has its OS 9 installation, you can check to be sure by restarting into OS 9. (System Preferences > Startup Disk)
    If it happens in OS 9, too, you can be certain that the keyboard needs to be replaced.

Maybe you are looking for

  • Rename the Company Name in test company

    I did the backup then restore database from SQL Server. I noticed the test company has same Company Name only the Database Name is different from Original Database Name.   Can I rename the Company Name to distinguish with the Original Database now? 

  • Error in ESS configuration

    Hi, I am getting the below error, while trying to configure ESS time recording scenario. We are using "testess" user for JCO connection only. this user exist in backend system with the "SAP ALL" access, and its valid. I have check the some of the thr

  • Best photo editor?

    adobe photoshop

  • Wiki calendar path!!

    Hi! I'm working on ical server, wiki calendar for group! As I know it is not possible to send invitation if calendar is based on wiki, but may be it is possible to change path for wiki calendar so it could look on calendar which made no server __uids

  • Assigning keyboard shortcuts to actions not working

    I have two actions that I use quite often. I assigned keyboard shortcuts to them in the actions dropdown menu. However whenever I press the shortcut keys, nothing ever happens. I have tried changing the modifier key combinations......nada. If some ha