Question: So I'm trying to use a KeyBoardEvent honestly just for testing purposes.. what I'm doing does not seem to be working :/ Hopefully you guys can tell me where I'm derping. Thanks! 

```
package com.dillyg10.test.Keys;

import java.awt.Window;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class Keys extends JPanel implements KeyListener  {
    private static final long serialVersionUID = 1L;

    public Keys(){

    }

    public static void registerEvent(Window w){
        w.setFocusTraversalKeysEnabled(false);
        w.setFocusable(true);
        w.addKeyListener(new Keys());
    }
    public void keyPressed(KeyEvent e) {
        System.out.println(KeyEvent.getKeyText(e.getKeyCode()));
    }
    public void keyReleased(KeyEvent e) {

    }
    public void keyTyped(KeyEvent e) {

    }
    public static void gui() {

        JFrame frame = new JFrame("Keys");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        registerEvent(new Window(frame));

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args){
        SwingUtilities.invokeLater(new Runnable(){
            public void run(){
                gui();
            }
        });
     }
    }

```

This code is basically a test to determine if the keyboardevents work, i jsut print out the key when it's pressed.. but nothing is printed.

Answer: 
The problem is OS related, because it depends on how OS organizes data on the disk with its file system.

Usually, the disk is divided into blocks of fixed size to store the content of a file. When a byte is overwritten, only the (whole) block containing the byte is rewritten. When the file is appended, possibly the last block is rewritten, plus new blocks being allocated and "linked" to the file to store content of the appended data. These 2 operations are efficient under this scheme.

However, when some byte is inserted or deleted, usually, the file needs to be rewritten from the first block that contains the insert/delete change.

It is technically possible to reduce the time spent rewriting the file. For insert case, the OS can allocate a new block for the data inserted, "link" it to the file, and rewrite one or two neighbor blocks. For delete case, the OS can reduce the number of valid bytes in the blocks, rewrite the block, and/or "relink" the blocks in the file. As a disclaimer, the "solution" I just mentioned are dependent on how the specific file system is structured. However, if you reduce the cost of rewriting the file, usually, it will incur a hit on the read operations later, or internal fragmentation will occur.

Maybe the problem will be solved, if someone one day invented a data structure that allows efficient insertion/deletion of data on disk while maintaining the performance of read operation.
You can modify a file in place; if the data you are replacing is the same size as the data you are replacing (smaller and you just pad). What if it is larger? Well, then everything after the modification would need to be rewritten to disk anyway, right? You also can't assume you have enough room at the end in all cases, so the file may need to be moved to a completely new location.

Obviously this makes the valid use cases rather rare. Normally it's not worth it unless you have a really good reason to do so. As for whether or not you have access to in-place modification API's in Python... I have no idea.