Key Press Anyone? SImple Q?

Hi, and thanks in Advance!!!
So i have a button that needs to be activated from the key
board.
Does anyone have a completed script that will allow the user
to activate this button that has sound attached to it from hitting
the letter "A" ?
Also, the sound file that i want to have play on the button
is on the "Down State" of pressing. I kinda of need the sound to
play in both instances. When the letter on the keyboard is clicked
and when you actually use your mouse.
Thanks A Million! I
Adam

You can't really call to a button instance to 'activate' it,
you could do so if your 'button' is an MC. I would recommend using
a Sound Object on the timeline for your event sound, then you can
control it from either call, the keyboard or the button. Ardy15jan,
has the correct calls for the keyboard above, just add aditional
code for your button instance to activate the sound.
To construct a Sound Object, you will need to import the
sound to the library, and add a 'linkage identifier', like
'sound_id' then attach the sound in script on the first frame of
the main timeline like so:
var mySound:Sound = new Sound();
mySound.attachSound('sound_id');
...Then, construct an on handler for the button instance and
call the sound:
myButton.onPress = function() {
mySound.start();
...and in the code for the keyboard as above where Ardy15jan
has 'Activate you button' place the start() method:
mySound.start();
...there you go :)

Similar Messages

  • Why i am unable to catch the 'TAB' key press?

    hi
    i have an application where i have 2 text fields and one button in order say t1, t2 and b1.
    on tabbing t1 cursor moves to t2 and on tabbing t2 cursor moves to b1 and on tabbing b1 cursor moves to t1.
    now when i press tab button on any of the component i have written a keyListener for that to catch 'TAB' key using the comparision
    if( e.getKeyCode() == KeyEvent.VK_TAB )
    but its not catching the tab key pressed on any of these 3 components....
    why like this...
    i want to catch the press of 'TAB' key and write some action for it... but unable to catch the 'TAB' key press.
    anyone could help me in this....
    thanx in advance,
    -Soni

    I seem to remember this question being asked before. I think the answer was that the FocusManager intercepts the TAB key. I don't remember the solution but you can try searching the forum.

  • How to change a h:outputText value in the current form on key pressed event

    Hello Suners,
    Greetings! I'm developing my first JSF web application and i'm trying to figure a way out to change outputText value when key pressed on another inputText so that when the user is typing his name for example he can see the letters showing respectively in the outputText.
    I managed to do it onchange but the user must focus out of the inputText to see his name in the outputText which is not right and the form must submit onchange event which is annoying.
    <h:inputText value="#{login.username}" title="name" id="name" required="true" onchange="this.form.submit()" >
                                <f:validateLength maximum="10" minimum="1"/>
                                <f:validator validatorId="myValidator"/>
                                <f:valueChangeListener type="classes.MyListener"/>
    </h:inputText>Is there any listener i can associate with the "onkeypress" attribute? Can anyone help me to do that with JSF?
    King Regards,

    hi, with JSF 2 you got the ajax tag, just tried it and it works fine :)
    <h:inputText id="myinput" value="#{back.name}">
        <f:ajax execute="@this" event="keyup" render="outtext"/>
    </h:inputText>
    <h:outputText id="outtext" value="#{back.name}"/>or before JSF 2
    <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
    <h:inputText id="myinput" value="#{back.name}" onkeyup="jsf.ajax.request(this, event, {render: 'outtext'}); return false;"/>
    <h:outputText id="outtext" value="#{back.name}"/>The name property is a simple String in the bean.
    Hope this helps
    Edited by: hereps on Aug 21, 2010 7:18 AM

  • "Enter Passcode" screen not showing the dots for key press

    I've a passcode that is 6 characters long. When I slide to unlock my phone , the "Enter Passcode" screen comes up as normal, but sometimes when I try to enter my passcode in the white box, though the key press turns blue under my finger tips as normal but nothing (no black dots) is entered into the white box. Whenever this happens I'm not able to unlock my phone with the passcode and I've to power off and power on the phone to detect the passcode.
    Not sure anyone else having the same problem as mine. If anyone encountered the same problem and know how to fix it, please help me.
    Thanks!

    I have two iPhone 4S both with iOs7 and simple passcode. One had the dots, the other didn't. I went through changing settings on the one without dots to match the settings to the one with dots one at a time until they came on.
    For me the exact change was turning on the Auto Brightness setting.
    Settings > Wallpapers and Brightness > Auto-Brightness
    Perhaps it's the same bug for complex passcodes? Worth a try.

  • ActiveX is stealing my key presses?

    Hi all,
    I have a fairly simple front panel with a handful of LabVIEW controls and an ActiveX container. In the ActiveX container is the Adobe Reader plugin.
    My vi works, but exhibits an odd behaviour that I presume is focus related. Once the ActiveX control is programmatically told to open and display a pdf file, it seems to steal the focus - permanently. If I select my LV string control, I can select any text in it, but key presses are all still sent to the Adobe Reader ActiveX control. If I click a few check boxes, then the string control again, it still doesn't accept my keyboard presses. The only way I've found to stop all this is to press tab, as this causes LabVIEW to move the focus away to the next control in the tab sequence. After that, all is ok until the next pdf file is read into the ActiveX control, and then I'm back at square one.
    Now I don't want to be telling my customers, "that's alright mate, just make sure you press the tab key after every pdf you generate and you'll be just fine."
    I've tried programmatically moving the focus away from the ActiveX control, and setting "SkipTabbing" to true, but this doesn't work.
    Anyone know how I can prevent this darned ActiveX control from permanently stealing my focus?
    Thoric (CLA, CLED, CTD and LabVIEW Champion)
    Solved!
    Go to Solution.

    nathand wrote:
    Unfortunately I don't have a good solution, but I can sympathize - I've had the same problem.
    Hi nathand, thanks for the sympathy 
    I've tried a few things, including navigating away from and straight back to the tab panel which houses the control to attempt to change the control focus. I've even tried simulating the keyboard TAB key press, which actually works - but only once for some annoyingly unfathomable reason! A second call to the ActiveX AdobeReader control makes it the focus again, but this time permanently. I've even tried putting the ActiveX control into a subvi that's hosted within a subpanel - no difference.
    Ultimately, like yourself, I've had to settle for a separate window, which I've called a Preview Window. Of course, putting my large ActiveX container in a separate subvi has left a dirty big empty space on my main vi front panel 
    I'm tempted to try to hide all borders around the preview window, and programmatically control its location such that it sits perfectly over the empty space within my main front panel. Of course, this means monitoring main panel window resizes and movements to maintain the correct relative locations, but it's do-able...
    I've got a new problem now - I thought about using Invoke to Get the Front Panel Image, then place this into a picture control. However, it seems the AdobeReaderActiveX control evades the LabVIEW Front Panel Image method, revealing nothing but the blank front panel colour behind the container. I can't seem to find a way around this either!
    Dam dam dam dam dam dam dam dam dam dam dam dam!!!
    Thoric (CLA, CLED, CTD and LabVIEW Champion)

  • Key Press Event

    I have been pouring through the TLF API docs looking for
    events to handle key presses on a TextFlow and I am not finding
    anything. I'm sure it's simple, can anyone give me a clue? I'm
    looking to detect Ctrl+B, Ctrl+I, etc.. to trigger formatting.

    The events go to the DisplayObjectContainerController. You
    will want to override the processKey event functions to add special
    handling. Those are in the protected methods section and are
    inherited from a base class.

  • Left and right key press going to different markers

    Hello there does anyone know exactly how to set the key press
    of the left and right arrow keys on the key board so when i press
    the left key it goes back a marker and when pressing the right key
    it goes to the next marker. I am fairly new to lingo so any help
    would be great and as simple as possible thanks

    Hi,
    I've created a slide show type application where arrow keys
    as well as PageUp and
    PageDown were used to move forward and back. Forward and Back
    were not always
    'previous' or 'next' markers. So, I created buttons on the
    stage that acted as
    forward and back, and each button had the regular mouseUp
    event with the link to
    the suitable location. I actually put the buttons off stage
    and in a movie script
    at:
    on keyDown
    case the keyCode of
    121 : sendSprite (10, #mouseUp) -- pageUp
    116 : sendSprite (11, #mouseUp) -- pageDown
    end case
    end
    Using the 'sendSprite', when the user pressed a key, I could
    activate the behavior
    attached to the related navigation sprite. And, I could
    easily add or remove key
    controls by changing the movie script.
    I have more info on using sendSprite, sendAllSprites and call
    commands at::
    http://www.deansdirectortutorials.com/Lingo/sendSprite.htm
    regards
    Dean
    Director Lecturer / Consultant / Director Enthusiast
    http://www.deansdirectortutorials.com/
    http://www.multimediacreative.com.au
    email: [email protected]

  • Amount of key presses a user makes over time - BPM

    Hi,
    Im working on a small program that needs to get the amount of keypresses a user makes over time.
    Basically its for calcuating the BPM a user is inputting. So a uers taps a beat for 5 seconds and the amount of tap is saved and multiplied by 12 to get the Users BPM.
    So far i have this:
    package Version1;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.Timer;
    import java.util.TimerTask;
    import javax.swing.*;
    public class muTap extends JFrame implements KeyListener, ActionListener {
        JTextArea display;
         * main - the main method
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    theGUI();
         * muTap constructor
        public muTap(String name) {
            super(name);
         * theGUI - creates the gui for muTap
        public static void theGUI() {
            muTap frame = new muTap("muTap");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Set up the content pane.
            frame.addComponents();
            //Display the window.
            frame.pack();
            frame.setVisible(true);
         * adComponents - adds gui components to muTap
        public void addComponents() {
            JButton button = new JButton("Start");
            button.addActionListener(this);
            display = new JTextArea();
            display.setEditable(false);
            display.addKeyListener(this);
            JScrollPane scrollPane = new JScrollPane(display);
            scrollPane.setPreferredSize(new Dimension(375, 125));
            getContentPane().add(scrollPane, BorderLayout.PAGE_START);
            getContentPane().add(button, BorderLayout.PAGE_END);
        public void keyTyped(KeyEvent e) {
            //Do Nothing
        /** Handle the key pressed event from the text field. */
        public void keyPressed(KeyEvent e) {
            //TODO call the getBPMfromKboard() method
            taps++;
            System.out.println("Tap: " + taps);
        /** Handle the key released event from the text field. */
        public void keyReleased(KeyEvent e) {
            //Do Nothing
        /** Handle the button click. */
        public void actionPerformed(ActionEvent e) {
            //Do Nothing
            //initialCountdown(3, "Start Tapping Fool");
            countDown(3);
         * countDown - a simple countdown timer for use when getting users input.
         * @param time amount of time to count down from
         * @return      true when timer ends.
        public static int taps;
        public void countDown(final int time) {
            taps = 0;
            final Timer timer = new Timer();
            timer.scheduleAtFixedRate(new TimerTask()
                int i = time;
                public void run()  {
                    i--;
                    String s = Integer.parseInt(i); // error because of this i.
                    display.setText(s);
                    if (i < 0) {
                        timer.cancel();
                        if(time == 3)
                            display.setText("Start Tapping");
                            countDown(5);
                        else if(time == 5)
                            display.setText("Number of taps: " + taps);
                            //System.out.print("Number of taps" +taps);
            }, 0, 1000);
    }But i get errors when i try running it:
    "Exception in thread "Timer-1" java.lang.RuntimeException: Uncompilable source code"
    It doesnt seem to like me parsing int to string here:
    String s = Integer.parseInt(i); Any ideas? or if youve got suggestions on another way to do it it'd be much appreiated.
    Thanks!

    Korvanica wrote:
    It doesnt seem to like me parsing int to string here:
    String s = Integer.parseInt(i);
    Yikes, you've got that bit of code backward, there partner.
    You use Integer.parseInt to parse a String into an int, not the other way around.
    If you want to change an int to a String, do
    String s = String.valueOf(i)or you can use the various formatters out there.

  • Trap Key pressed in Forms 10g.

    Hi All,
    Have anyone trapped the keys which are pressed in Forms 10g. We have a requirement in which in a LOV Form when TAB key is pressed it should navigate to the next field and when ENTER key is pressed it should select the value from that field and get back to the field from where it was invoked.
    We had tried http://forms.pjc.bean.over-blog.com/article-15980196.html from Francois Degrelle which traps he key pressed. But that is throwing us some error in JInitiator console.
    Expecting a favorable reply from the forum users on this to .
    Thanks in advance

    Monsieur Degrell,
    is it possible to listen just to one item in the form?
    I have triedSet_Custom_Property( 'b_hilfe.bean', 1, 'INIT', 'b_help.search');in when-new-form-instance, where 'b_help.search' is the item i want to listen to,
    but the bean still listen on every item in the form.
    kind regards

  • Closing windows in Expose using key press (or why does apple-W not work?)

    I often end up with lots of Safari windows open & need to prune them down. (Yes I use tabbed browsing too .
    So I thought I'd use Expose, see the windows I needed to close, select the one I wanted to close and hit apple-W which works fine to close a window when not in Expose. However for me it doesn't work in expose (though its fine when not in expose).
    This leads to a rather slow process of going into expose, selecting the window you want to close, coming out of expose, then hitting apple-W to close that window, then going back to expose.
    I'd much rather just go into expose, hover over the window I want to close (or use cursor keys to pick the right one) and hit apple-W; then I can close a few windows without having to leave expose.
    Has anyone ever figured out a way to get apple-W - or any key press at all - to close the currently selected window in expose?
    BTW I know you can quit an application in Expose; which is great. However in this case I want to close just a selected window in expose (e.g. a particular safari window), not the whole application.

    You have a great idea. But it isn't supported. Yet.
    Send your idea to Apple (they read all submissions) http://www.apple.com/macosx/feedback

  • Recognizing multiple key presses in As3

    Hi,
    I have a simple game with three keyboard inputs - left, right and fire
    I want to be able to log when a key is pressed and released. In the game, you can be in the following states:
    None
    Left only - keyz on the keyboard
    Right only - keyc on the keyboard
    Fire only - keyx on the keyboard
    Left and Fire - keyz and Keyx on the keyboard
    Right and Fire - Keyc and Keyx on the keyboard
    When Left key is pressed for example, it should log LeftKeypressStart and when it is released, it shoul log leftKeyPressStop. The same should happen to Right and Fire keys when they are pressed individually.
    Now, for the game to be in  Left and Fire state either of the three conditions are true:
    Left key can be pressed and held down before the fire button is pressed and held down or
    Fire button is pressed and held down before left is pressed and held down or
    Both keys pressed down simultenuosly (although this condition will rarely occur as we are not robots)
    Similar conditions should be true for the game to be in the Right and Fire State
    Now considering the first condition,when Left key is down, I want the game to log LeftKeypressStart but as soon as the Fire key is down, it should log LeftKeyPressStop and also Log LeftandFireKeypressStart. Then if Fire is released first, I want it to log LeftandFirKeypressStop and then log LeftKeyStart. but if Left is released first, it should log  LeftandFirKeypressStop and then lof FireKeyPressStart.
    This is what I have at the minute:
    private function onKeyPress (evt:KeyboardEvent)
    if (evt.keyCode == 67 && evt.keyCode !=88 && evt.keyCode != 90)
    //log Right  
    else if (evt.keyCode != 67 && evt.keyCode !=88 && evt.keyCode == 90 )
    //log Left
    else if (evt.keyCode != 67 && evt.keyCode !=90 && evt.keyCode == 88)
    //log Fire
    else if (evt.keyCode == 67 && evt.keyCode !=90 && evt.keyCode == 88 )
    //log RF
    private function onKeyRelease(evt:KeyboardEvent)
    if (evt.keyCode == 67 && evt.keyCode !=88 && evt.keyCode != 90)
    //stop right
    else if (evt.keyCode != 67 && evt.keyCode !=88 && evt.keyCode == 90 )
    //stop Left
    else if (evt.keyCode != 67 && evt.keyCode !=90 && evt.keyCode == 88)
    //stop Fire
    else if (evt.keyCode == 67 && evt.keyCode == 88  && evt.keyCode !=90 )
    // stop RF    

    There can only be one evt.keyCode per keypress, so your approach will not work.  All you need to do is determine which key caused the function to execute.  If you want to keep track of which keys are down, just create three Boolean variables, as in...
    var leftDown:Boolean = false;
    var rightDown:Boolean = false;
    var fireDown:Boolean = false;
    and set those values to true or false and make use of them in whatever other code you intend.
    private function onKeyPress (evt:KeyboardEvent)
    if (evt.keyCode == 67)
                 rightDown = true  
    else if (evt.keyCode ==88)
                 leftDown = true
    else if (evt.keyCode == 88)
                 fireDown = true
    // process per whatever values are true/false
    and in the key up function set them back to false in a similar fashion.

  • Multiple key press's with Bluetooth Keyboard

    I'm ready to update my mac to a new G5 imac and fancy getting the wireless bluetooth keyboard and mouse with it.
    I have one question, has anyone experienced problems when holding down multiple keys on the keyboard and moving the mouse all at once (Using illustrator)?
    In my office I have the misfortune of having to use a PC, I have had a number of wireless keyboard and mouse combos, all of them when using Illustrator and photoshop can not handle multiple key press's and mouse movement.
    ie if I'm duplicating an object by dragging a copy of it across the screen, on the PC it will work but it always "releases" after a couple of seconds and drops the copy in the where I don't want it which gets very frustrating (this only happens with wireless).
    As I do a lot of work at home, I hoping this wont be the case with the mac's bluetooth K & M.
    thanks
    Russell

    The shift key works just fine on my Bluetooth keyboard.  So I would imagine this is an issue with your keyboard.

  • Key pressed in Jlist and selecting the item of key list accordingly

    Hi,
    I have a JList with the items in sorted order.Now I want that if a person presses any key (say K) then the first item starting with K should be selected.Hmmm I can do it by addding a key listener to the list and cheking all the items in the list ,by traversing through the whole lenght of JList and selecting the item if it starts with the character of the key pressed.
    But i was thinking if there is any better way to do that?
    Regards Amin

    see bugid: 4654916 - it does say that the the
    scrolling for the JList should now work with keyboard
    selection.I have the same problem. Thanx for the hint with the bugid. Saw a good workaround there with a simple subclass of JList. Works for me although it is annoying to subclass JList all the time. The bug seems not to be fixed in the 1.4.1 JDK.
    Andreas

  • Key Press CTRL+Space

    How do I view a JInternalFrame by pressing CTRL+Space from a JTextFeild in another JInternalFrame? Using isControlDown() works but throws NullPointerException. Can it be done by using KeyStroke ? If Yes then how?

    Thanks! I changed the InternalFrame which I wanted to see after pressing. I used A JPanel in which there is a JList. What I tried is pretty simple and like this
    private void jTextFieldlBankIDKeyPressed(java.awt.event.KeyEvent evt) {
    try{
    int keyCode=evt.getKeyCode();
    int modifier=evt.getModifiers();
    int iSpace=java.awt.event.KeyEvent.VK_SPACE;
    if(evt.isControlDown()&& keyCode==iSpace){
    jPanel2.setVisible(true);
    //setValueAtTheList();
    //jList1.grabFocus();
    System.out.println("Key Pressed");
    }catch(NullPointerException e){
    I got what I need but the exception is there like before,
    java.lang.NullPointerException
    at javax.swing.plaf.basic.BasicInternalFrameUI$1.actionPerformed(BasicInternalFrameUI.java:153)
    at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1502)
    at javax.swing.JComponent.processKeyBinding(JComponentKey Pressed
    .java:2422)
    at javax.swing.KeyboardManager.fireBinding(KeyboardManager.java:253)
    ������������.

  • Wish you could tap the Shift key to set next key press in caps on iMac

    I really wish in Mac OS that you could 'tap' the Shift key to set up the next key press in capitals.  In Lion, on my iMac desktop, the present arrangement requires you to hold down the Shift key while hitting the letter you want to capitalise, as has been the case since time began.  On my lovely iPad2, you just tap the shift key once and the next keypress is in caps - SIMPLE and efficient.  I have been yearning for this simple change to the OS since way before the iPad came along, but now you can use it in iOS5 and NOT in Lion, it's really frustrating.  i find i am now failing time after time to select caps in Lion...
    Please, oh wise ones at Apple: take a few minutes out from whatever fresh ramification of iCloud you are concocting and giVe uS bETter cAps.

    There is this, but it might do more than you want:

Maybe you are looking for

  • How can I use apple remote with Mountain Lion? Any Front Row alternative?

    Hi All, I recently upgraded from Snow Leopard to Mountain Lion. All great except for my Apple Remote control. Before, I could effectively control my iMac media with Apple Remote by using Front Row (music, photos, videos, good integration with iTunes

  • Java.util.zip.ZipException: error in opening

    i ahve problem unzipping some zip file any one help me the zip file is name PRICE.ZIP and content is PRICE.TXT Please help code                //zf will contain the actual zip file object                System.out.println("FILE TO UNZIP"+SERVER_DIREC

  • Daisy Chaining Thunderbolt Monitors

    I see that a 15 inch Macbook can drive two daisy chained Thunderbolt monitors.  Can a post 2012 Air Book also do this? Going in another direction, if i use the 15 Inch Macbook with a thunderbolt monitor, can i daisy chain in a Cinema Display to that?

  • XML Messages in report format

    Hi all, Is there a way i can present the XML messages in a report format? I have the table SXMSPMAST to get the message ID and using class CL_XMS_PERSIST we can get the entire message. But, i need to collate the different messages in different nodes

  • Erratic Temperature measurements with FP-TC-120

    I have two FP-TC-120 modules on a furnace system. When the temperature reaches a certain level (930°C) my readings become very erratic. I have shielded all of the tc's and everything else that is connected to the FP bank to eliminate EMI noise. The i